SQL Oracle 更改表权限不足
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22639951/
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 alter table insufficient privileges
提问by pdevel
I have just installed oracle 12c and then i am trying to grant user various rights.
我刚刚安装了 oracle 12c,然后我试图授予用户各种权限。
I am logged in as system and i had given rights for create user
which worked. However, while granting rights for alter table
it gave me error
我以系统身份登录,并且我已授予create user
其有效权限。然而,虽然授予alter table
它的权利给了我错误
ORA-00990: missing or invalid privilege
ORA-00990: missing or invalid privilege
Researching on this problem brought me to another poston SO. The Comments on this post indicated that it is because i am not logged in as GLOBAL
user.However i don't know how to log in as GLOBAL
user.
在研究这个问题把我带到了另一个岗位上SO。这篇文章的评论表明这是因为我没有以用户身份登录。GLOBAL
但是我不知道如何以GLOBAL
用户身份登录。
Do i have to create one ?
我必须创建一个吗?
Is there any alternative solution ?
有什么替代解决方案吗?
回答by Alex Poole
There is no ALTER TABLE
privilege. The valid privileges are listed in the documentation.
If you have CREATE TABLE
then you can create and alter your own table. To alter the definition of a table in another schema you'd need the ALTER ANY TABLE
privilege.
如果有,CREATE TABLE
则可以创建和更改自己的表。要在另一个模式中更改表的定义,您需要ALTER ANY TABLE
特权。
Curiously this pagedoes refer to ALTER TABLE
:
奇怪的是,此页面确实引用了ALTER TABLE
:
For example, to create a trigger on a table, the user requires both the
ALTER TABLE
object privilege for the table and theCREATE TRIGGER
system privilege.
例如,要在表上创建触发器,用户需要表的
ALTER TABLE
对象权限和CREATE TRIGGER
系统权限。
The ALTER TABLE
command prerequisitesalso say:
The table must be in your own schema, or you must have
ALTER
object privilege on the table, or you must haveALTER ANY TABLE
system privilege.
该表必须在您自己的架构中,或者您必须
ALTER
对该表具有对象权限,或者您必须具有ALTER ANY TABLE
系统权限。
In this context it's a bit clearer; 'ALTER
object privilege' means that you've been directly granted ALTER
on the table by its owner, rather than via the ALTER ANY TABLE
system privilege, as in:
在这种情况下,它更清楚一些;“ALTER
对象特权”意味着您已被ALTER
其所有者直接授予该表,而不是通过ALTER ANY TABLE
系统特权,如下所示:
create table t42(id number);
grant alter on t42 to user2;
Then user2
would be able to alter table t42 ...
, or create a trigger on it (for example), but not any other tables.
然后user2
将能够alter table t42 ...
,或在其上创建触发器(例如),但不能创建任何其他表。
回答by Dmitry Nikiforov
Trying to figer out what is the problem I guess you execute something like
试图找出问题所在,我猜你执行了类似的操作
SQL> conn system/***@***
Connected.
SQL> grant alter table to scott;
grant alter table to scott
*
error in line 1:
ORA-00990: missing or invalid privilege
In accordance to Oracle documentation:
根据 Oracle 文档:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_9013.htm#BABEFFEE
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_9013.htm#BABEFFEE
you can grant ALTER ANY TABLE (which is a powerful right) or grant ALTER privilege on particular table in another schema:
您可以授予 ALTER ANY TABLE(这是一项强大的权利)或授予另一个架构中特定表的 ALTER 权限:
SQL> grant alter any table to scott;
Granted.
SQL> grant alter on hr.event to scott;
Granted.
Schema owner always has ALTER privilege over the objects it's owned:
架构所有者始终对其拥有的对象具有 ALTER 权限:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_3001.htm#CJAHHIBI
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_3001.htm#CJAHHIBI
"Prerequisites
“先决条件
The table must be in your own schema, or you must have ALTER object privilege on the table, or you must have ALTER ANY TABLE system privilege."
该表必须在您自己的架构中,或者您必须对该表具有 ALTER 对象权限,或者您必须具有 ALTER ANY TABLE 系统权限。”
SQL> conn scott/tiger@***
Connected.
SQL> select * from session_privs;
PRIVILEGE
----------------------------------------
CREATE SESSION
UNLIMITED TABLESPACE
CREATE TABLE
CREATE CLUSTER
CREATE SEQUENCE
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE
CREATE OPERATOR
CREATE INDEXTYPE
SQL> create table t(x int);
Table created.
SQL> alter table t add (y int);
Table altered.