ORA-01031: insufficient privileges
Your user is missing a system or object privilege needed for the statement — for example CREATE TABLE, ALTER SYSTEM or EXECUTE on a package. Inside definer’s-rights PL/SQL, privileges granted through roles do not count.
What it means
Oracle checks privileges for every statement. ORA-01031 means the statement was understood and the object was found, but your user is not allowed to perform the action. It is common when code that works in a worksheet fails inside a stored procedure, because roles are disabled in definer’s-rights units.
Common causes
- Missing system privilege such as
CREATE TABLE,CREATE VIEWorALTER SYSTEM. - Missing object privilege such as
UPDATE,DELETEorEXECUTEon another schema’s object. - The privilege comes through a role, but the statement runs inside a definer’s-rights procedure.
- Trying to connect AS SYSDBA without being in the right OS group or password file.
How to fix it
- List what you have:
SESSION_PRIVS(system privileges) andSESSION_ROLES. - Ask the object owner or a DBA for exactly the missing privilege.
- For stored procedures, grant the privilege directly to the procedure owner, or use invoker’s rights (
AUTHID CURRENT_USER) where appropriate. - Avoid granting broad
ANYprivileges just to fix one error.
Example
What can I do right now?
SELECT privilege FROM session_privs ORDER BY privilege;
SELECT role FROM session_roles ORDER BY role;
Direct grants for a procedure owner:
GRANT CREATE TABLE TO app_owner;
GRANT UPDATE ON hr.employees TO app_owner;
In SQLlightspeed
When a statement fails, SQLlightspeed’s error panel shows the error code with a plain-language explanation and a suggestion for what to do next, together with Oracle’s own message and a link to Oracle’s documentation — for this error and dozens of other common ones.
Related errors
ORA-00942ORA-01017ORA-00054 All Oracle errors →
Oracle documentation for ORA-01031. Oracle is a registered trademark of Oracle Corporation. SQLlightspeed is not affiliated with Oracle.