oracle 授予在特定表上创建索引

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

grant create index on specific table

sqloracle

提问by Djaballah DJEDID

I'm using oracle and I want to create an index to a specific table belongs to another user so how I grant the privilege to do so without using the requete

我正在使用 oracle,我想为属于另一个用户的特定表创建一个索引,所以我如何在不使用 requete 的情况下授予这样做的权限

grant create any index 

回答by mathguy

grant index on [tablename] to [user]

What privileges the table owner him/herself must have in order to be allowed to grant create index on a table to another user will depend on your version of Oracle; check the documentation.

表所有者他/​​她自己必须拥有哪些权限才能将表上的创建索引授予另一个用户,这取决于您的 Oracle 版本;检查文档。

回答by Dante Fa?a Badia

If you want to create a index to a table in another schema first you need to grant the system privilege to the user you want use to create de index.

如果要首先为另一个模式中的表创建索引,则需要将系统权限授予要用于创建索引的用户。

To create an index in another schema, you must have the?CREATE?ANY?INDEX?system privilege.

要在另一个模式中创建索引,您必须具有?CREATE?ANY?INDEX?系统特权。

More reference: https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5010.htm

更多参考:https: //docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5010.htm

Here the SQL:

这里的 SQL:

/*No tested*/
Grant create any index to user;

回答by Kacper

Create procedure in table owner schema

在表所有者架构中创建过程

create or replace 
procedure create_index(col_list varchar2, index_name varchar2) as
begin
execute immediate 'create index ' || index_name || ' on ' || 'PUT_TABLENAME_HERE'|| '(' || col_list || ')';
end;

GRANT EXECUTE ON table_owner.create_index TO user;

Call

称呼

begin
table_owner.create_index('ID','IDX1');
end;

I think it should work.

我认为它应该工作。