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 Solution: Go to Your System User. then Write This Code: SQL> grant dba to UserName; //Put This username which user show this error message. Grant succeeded.
You may be seeing the Ora-00942 error because you are referencing a table or view in a schema which you did not create but one that is in another schema. To correctly execute the query from another schema, you must reference the table by the schema name.
The solution is simple, just grant him CREATE TABLE, a schema-based privilege or CREATE ANY TABLE, a system-wide privilege. Connected. SQL> grant create table to thomas; Grant succeeded.
The ORA-01031: "insufficient privileges" error occurs when you attempt to execute a program or function for which you have not been granted the appropriate privileges.
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.
Create schemas
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.
Create objects and privileges
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.
Connect as TEST_USER and try to query the tables
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: insufficient privileges
happens when the object exists in the schema but do not have any access to that object.
ORA-00942: table or view does not exist
happens when the object does not exist in the current schema. If the object exists in another schema, you need to access it using .. Still you can get insufficient privileges error if the owner has not given access to the calling schema.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With