获取ORA-01031:查询表而不是ORA-00942时权限不足:表或视图不存在 [英] Getting ORA-01031: insufficient privileges while querying a table instead of ORA-00942: table or view does not exist
问题描述
从架构A查询架构C中的表时,我得到 ORA-01031:权限不足,而从架构B中查询同一表时,我 ORA-00942:表或视图不存在.在表上,这两个模式都不具有任何特权.为什么在这种情况下我会收到不同的错误消息?
When I'm querying a table in schema C from schema A, I'm getting ORA-01031: insufficient privileges and when I'm querying the same table from schema B, I'm getting ORA-00942: table or view does not exist. On the table neither of the schemas are having any privileges. Why am I getting different error messages in this case?
推荐答案
当您对表具有至少一个特权,但没有必需的特权时,可能会得到ORA-01031: insufficient privileges
而不是ORA-00942: table or view does not exist
.
You may get ORA-01031: insufficient privileges
instead of ORA-00942: table or view does not exist
when you have at least one privilege on the table, but not the necessary privilege.
创建架构
SQL> create user schemaA identified by schemaA;
User created.
SQL> create user schemaB identified by schemaB;
User created.
SQL> create user test_user identified by test_user;
User created.
SQL> grant connect to test_user;
Grant succeeded.
创建对象和权限
这是不常见的,但有可能在不授予SELECT的情况下授予模式类似DELETE的特权.
It is unusual, but possible, to grant a schema a privilege like DELETE without granting SELECT.
SQL> create table schemaA.table1(a number);
Table created.
SQL> create table schemaB.table2(a number);
Table created.
SQL> grant delete on schemaB.table2 to test_user;
Grant succeeded.
以TEST_USER身份连接并尝试查询表
这表明在表上具有 some 特权会更改错误消息.
This shows that having some privilege on the table changes the error message.
SQL> select * from schemaA.table1;
select * from schemaA.table1
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from schemaB.table2;
select * from schemaB.table2
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL>
这篇关于获取ORA-01031:查询表而不是ORA-00942时权限不足:表或视图不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!