Oracle:授予在另一个模式中创建表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21412747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle : Grant Create table in another schema?
提问by Thomas Carlton
I have two users : Schema1 and Schema2
我有两个用户:Schema1 和 Schema2
How to grant Create Table privilege On Schema2 to Schema1 ?
如何将 Schema2 上的创建表权限授予 Schema1?
I have been turning around and I got confused. I tried :
我一直在转身,我感到困惑。我试过 :
From Schema2 I tried,
从我尝试过的 Schema2,
GRANT CREATE TABLE TO SCHEMA1 WITH ADMIN OPTION;
But it seems like this grants Creating table to Schema1 in its own Schema and not in the Schema2.
但这似乎在其自己的架构中而不是在 Schema2 中将创建表授予 Schema1。
Any ideas please ?
请问有什么想法吗?
Thank you.
谢谢你。
回答by A B
The only other way to allow a non-DBA user to create a table in another schema is to give the user the CREATE ANY TABLE
system privilege.
允许非 DBA 用户在另一个模式中创建表的唯一其他方法是授予用户CREATE ANY TABLE
系统权限。
This privilege can only be given to SCHEMA1 by a user with DBA privileges.
此权限只能由具有 DBA 权限的用户授予 SCHEMA1。
回答by René Nyffenegger
You want to grant create ANY table
:
你想授予create ANY table
:
grant create any table to schema1;
The any
"modifier" allows to create tables in other than own schemas.
在any
“修改器”允许创建其他比自己的模式表。
回答by blantomat
Better solution (minimizes the security threat that comes with CREATE ANY TABLE
privilege...)
更好的解决方案(最小化CREATE ANY TABLE
特权带来的安全威胁......)
- Create a procedure on schema2 that takes a table definition as a "input" parameter (e.g. p_tab_def in varchar2(4000).
- Inside put an execute_immediate(p_tab_def); statement. You MUST check the p_tab_def first in order to defend yourself from other DDL statements than "CREATE TABLE [...]". (e.g. you could use a simple check by checking first two words -> it must be "CREATE TABLE").
GRANT EXECUTE ON schema2.procedure_name TO schema1;
- 在schema2 上创建一个过程,该过程将表定义作为“输入”参数(例如varchar2(4000) 中的p_tab_def)。
- 里面放一个 execute_immediate(p_tab_def); 陈述。您必须首先检查 p_tab_def 以保护自己免受除“CREATE TABLE [...]”之外的其他 DDL 语句的影响。(例如,您可以通过检查前两个单词来使用简单的检查 -> 它必须是“CREATE TABLE”)。
GRANT EXECUTE ON schema2.procedure_name TO schema1;
It's a simple concept ... I've used such concepts in my previous job.
这是一个简单的概念......我在以前的工作中使用过这样的概念。