oracle 在另一个架构上创建表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15188878/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:29:15  来源:igfitidea点击:

Create table on another schema

oracleoracle11g

提问by Fuv

Situation is that user1 gives permision to user2:

情况是 user1 授予 user2 权限:

GRANT CREATE ANY TABLE, SELECT ANY TABLE TO user2;

And after logging on user2, I'm trying to create table:

登录 user2 后,我正在尝试创建表:

CREATE TABLE user1.test(id NUMBER PRIMARY KEY);

the result is ORA-01031 - insufficient privilegesI can create table on own schema and select tables from other schemas. I thought that CREATE ANY TABLEsolves the problem, but it looks other way. Ah, and both users have unlimited tablespace. What else should I guarantee?

结果是ORA-01031 - insufficient privileges我可以在自己的模式上创建表并从其他模式中选择表。我认为这CREATE ANY TABLE解决了问题,但它看起来是另一种方式。啊,两个用户都有无限的表空间。我还应该保证什么?

回答by DCookie

Perhaps you need to also grant CREATE ANY INDEX? You are creating an index when you add the primary key. You can quickly test this by omitting the PK constraint.

也许您还需要授予CREATE ANY INDEX?添加主键时,您正在创建索引。您可以通过省略 PK 约束来快速测试这一点。

回答by David Aldridge

"create any table" is too powerful a privilege to be granting to non-DBA's. A better approach would be to create a "create table" procedure in the target schema that accepts sanitised components of the required DDL, and grant execute privilege on that to the required users.

“创建任何表”是一项过于强大的特权,无法授予非 DBA。更好的方法是在目标模式中创建一个“创建表”过程,该过程接受所需 DDL 的净化组件,并将执行权限授予所需用户。

A suitable interface would be something like ...

一个合适的界面应该是这样的......

create procedure
  create_table(
    table_name varchar2,
    columns    varchar2,
    etc        varchar2)

... so that you can ...

……这样你就可以……

begin
  user1.create_table(
    table_name => 'TEST',
    columns    => 'id NUMBER PRIMARY KEY',
    etc        => '');
end;

... and have the procedure construct and execute the DDL for you.

... 并为您构建过程并执行 DDL。

回答by Amr Fawaz

user GRANT CREATE ANY INDEX TO SCHEMA_NAME

用户 GRANT CREATE ANY INDEX TO SCHEMA_NAME