Home > Back-end >  Can't select rows from table with user
Can't select rows from table with user

Time:05-05

I created a user and granted him all permissions, i used: GRANT ALL PRIVILEGES TO user1; but then i tried to select rows from a table that i created with the admin user like this: select * from sys.table it gives me an error message table or view doesn't exist

then i did: Grant select on table to user1 and it worked.

so does all privileges not include select?

CodePudding user response:

As is often the case, Oracle uses words "approximately".

In this case, ALL doesn't mean "all". From the documentation:

ALL PRIVILEGES

Specify ALL PRIVILEGES to grant all of the system privileges listed in Table 18-1, except the SELECT ANY DICTIONARY, ALTER DATABASE LINK, and ALTER PUBLIC DATABASE LINK privileges.

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/GRANT.html#GUID-20B4E2C0-A7F8-4BC8-A5E8-BE61BDC41AC3

Notice the "except" part. "All" should mean "all", that is, "no exception"; yet........

Relevant to your question: ALL PRIVILEGES does not include SELECT ANY DICTIONARY. Most likely, whatever table or view you were trying to select from is a dictionary table (or view); which explains why granting ALL PRIVILEGES didn't work, but granting access directly on the table/view did.

If you want to grant access to all dictionary objects, you can grant SELECT ANY DICTIONARY to the user.

After you are done playing with these explicit grants, you may want to consider granting system roles to the users who need them (and only to those users), instead of hunting down all such exceptions.

  • Related