Answers

Question and Answer:

  Home  Oracle Database

⟩ What Privilege Is Needed for a User to Query Tables in Another Schema?

For a user to run queries (SELECT statements) on tables of someone else's schema, he/she needs the SELECT ANY TABLE privilege. The following tutorial exercise gives you a good example of granting "dev" to query tables in "hr" schema:

>.insqlplus /nolog

SQL> CONNECT DEV/developer

SQL> SELECT COUNT(*) FROM hr.employees;

ORA-01031: insufficient privileges

SQL> disconnect

SQL> connect SYSTEM/globalguideline

SQL> GRANT SELECT ANY TABLE TO dev;

Grant succeeded.

SQL> disconnect

SQL> CONNECT DEV/developer

SQL> SELECT COUNT(*) FROM hr.employees;

COUNT(*)

----------

107

As you can see, "dev" can query tables in any schema now.

You also need to remember that table name must be prefixed with the schema name (same as owner user name).

 177 views

More Questions for you: