Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORA-01031: insufficient privileges when selecting view

Tags:

oracle

view

When I try to execute a view that includes tables from different schemas an ORA-001031 Insufficient privileges is thrown. These tables have execute permission for the schema where the view was created. If I execute the view's SQL Statement it works. What am I missing?

like image 437
Igor Zelaya Avatar asked Sep 26 '08 16:09

Igor Zelaya


People also ask

How do I fix Ora-01031 insufficient privileges?

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.

What do you mean by insufficient privileges?

You see the Insufficient Privileges error if you don't have the right access on different levels. For example, your profile prevents you from accessing the account object, or your role prevents you from accessing a case record.

What is the meaning of insufficient privileges in Oracle?

ORA-01031 Error Message “Insufficient Privileges” Error ORA-01031 means you are attempting to execute an operation for which you do not have appropriate privileges.


2 Answers

Finally I got it to work. Steve's answer is right but not for all cases. It fails when that view is being executed from a third schema. For that to work you have to add the grant option:

GRANT SELECT ON [TABLE_NAME] TO [READ_USERNAME] WITH GRANT OPTION; 

That way, [READ_USERNAME] can also grant select privilege over the view to another schema

like image 84
Igor Zelaya Avatar answered Sep 21 '22 04:09

Igor Zelaya


As the table owner you need to grant SELECT access on the underlying tables to the user you are running the SELECT statement as.

grant SELECT on TABLE_NAME to READ_USERNAME; 
like image 44
Steve K Avatar answered Sep 19 '22 04:09

Steve K