Oracle errors

ORA-01031: insufficient privileges

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

How to fix it

  1. List what you have: SESSION_PRIVS (system privileges) and SESSION_ROLES.
  2. Ask the object owner or a DBA for exactly the missing privilege.
  3. For stored procedures, grant the privilege directly to the procedure owner, or use invoker’s rights (AUTHID CURRENT_USER) where appropriate.
  4. Avoid granting broad ANY privileges 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.