Close Menu
  • Home
  • Oracle
    • ASM
    • Data Guard
    • OEM
    • RAC
  • MongoDB
  • Performance
  • Python
  • Shell Script
  • Tools
  • Troubleshooting
Search

Rolling Upgrade: Percona Server for MongoDB 8.0.23-10 to 8.0.26-11

2026-06-26 MongoDB By Henrique

Clone a MongoDB User and Preserve the Password Hash

2026-06-26 MongoDB By Henrique

ORA-06553: DBCA Fails on catalog.sql with PLS-213

2026-06-25 Oracle By Henrique
YouTube LinkedIn RSS
  • Home
  • About
  • Contact
  • Legal
    • Cookie Policy
    • Disclaimer
    • Privacy Policy
    • Terms of Use
  • RSS
  • English
    • Portuguese (Brazil)
Execute StepExecute Step
YouTube LinkedIn RSS
  • Home
  • Oracle
    • ASM
    • Data Guard
    • OEM
    • RAC
  • MongoDB
  • Performance
  • Python
  • Shell Script
  • Tools
  • Troubleshooting
Execute StepExecute Step
Home » ORA-01031- Insufficient Privileges When Creating an IDENTITY Column
Oracle

ORA-01031- Insufficient Privileges When Creating an IDENTITY Column

HenriqueBy Henrique2026-04-03Updated:2026-05-184 Mins Read
Share
Facebook Twitter LinkedIn Pinterest Email Telegram WhatsApp

This post is also available in: Português (Portuguese (Brazil))

You try to create a table with an identity column and Oracle throws a privilege error- even though you have CREATE TABLE. Here’s why it happens and how to fix it.

SQL> CREATE TABLE orders (
  2    id   INT GENERATED BY DEFAULT AS IDENTITY,
  3    desc VARCHAR2(100)
  4  );
  id   INT GENERATED BY DEFAULT AS IDENTITY,
*
ERROR at line 2:
ORA-01031: insufficient privileges

The error appears even with CREATE TABLE granted. The culprit is a different privilege that’s easy to overlook.


Why It Happens

Identity columns were introduced in Oracle 12c as a shorthand for the classic sequence + default pattern. Under the hood, when Oracle creates an identity column, it automatically creates an implicit sequence tied to that column. That sequence is managed by the database, but it’s still a sequence- and creating one requires the CREATE SEQUENCE privilege.

Without it, CREATE TABLE fails with ORA-01031 before the table itself is even touched.


Diagnosis

Check the current user’s system privileges:

-- System privileges for the current session
SELECT privilege
FROM   session_privs
ORDER BY privilege;

If CREATE SEQUENCE is not in the list, that’s the issue.

To check a specific user (as DBA):

SELECT privilege
FROM   dba_sys_privs
WHERE  grantee = 'MY_USER'
ORDER BY privilege;

Solution

Grant the CREATE SEQUENCE privilege to the user:

-- Connected as DBA
GRANT CREATE SEQUENCE TO my_user;

After the grant, table creation works as expected:

SQL> CREATE TABLE orders (
  2    id   INT GENERATED BY DEFAULT AS IDENTITY,
  3    desc VARCHAR2(100)
  4  );

Table created.

All Three IDENTITY Variants Require CREATE SEQUENCE

The behavior is identical across all three identity column forms available since Oracle 12c:

VariantBehaviorAlso fails without CREATE SEQUENCE?
GENERATED ALWAYS AS IDENTITYOracle always generates the value; explicit INSERT into the column is blocked✅ Yes
GENERATED BY DEFAULT AS IDENTITYOracle generates the value by default; explicit INSERT is allowed✅ Yes
GENERATED BY DEFAULT ON NULL AS IDENTITYOracle generates the value when NULL is passed on INSERT✅ Yes

Regardless of which variant you choose, Oracle always creates an implicit sequence behind the scenes- and CREATE SEQUENCE is always required.


How to Reproduce in a Lab

-- 1. Create a test user (connected as DBA)
CREATE USER lab_identity IDENTIFIED BY lab123;
GRANT CREATE SESSION TO lab_identity;
GRANT CREATE TABLE    TO lab_identity;
-- Intentionally WITHOUT CREATE SEQUENCE

-- 2. Connect as lab_identity and reproduce the error
sqlplus lab_identity/lab123@ORCLPDB1

CREATE TABLE t_identity (
  id   INT GENERATED BY DEFAULT AS IDENTITY,
  name VARCHAR2(50)
);
-- Expected: ORA-01031: insufficient privileges

-- 3. Switch back to DBA and grant CREATE SEQUENCE
CONNECT / AS SYSDBA
GRANT CREATE SEQUENCE TO lab_identity;

-- 4. Reconnect as lab_identity and confirm the fix
sqlplus lab_identity/lab123@ORCLPDB1

CREATE TABLE t_identity (
  id   INT GENERATED BY DEFAULT AS IDENTITY,
  name VARCHAR2(50)
);
-- Expected: Table created.

-- 5. Confirm the implicit sequence created by Oracle
SELECT sequence_name, min_value, max_value, increment_by, cache_size
FROM   user_sequences;

-- Cleanup
DROP TABLE t_identity;

Quick Checklist

-- 1. Check session privileges
SELECT privilege FROM session_privs ORDER BY privilege;

-- 2. Grant CREATE SEQUENCE (as DBA)
GRANT CREATE SEQUENCE TO my_user;

-- 3. Re-run the table creation
CREATE TABLE my_table (
  id INT GENERATED BY DEFAULT AS IDENTITY,
  ...
);

References

  • Oracle Database SQL Language Reference- Identity Columns
  • Oracle Database Security Guide- System Privileges

create sequence identity column lab ora-01031 troubleshooting
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
Previous ArticleORA-12547- TNS:lost contact When Connecting with sqlplus
Next Article EMD runCollection Error – OEM Agent Running but Not Collecting Metrics

Related Posts

Oracle

ORA-06553: DBCA Fails on catalog.sql with PLS-213

2026-06-25
Read More
Oracle

Oracle Data Pump: How to Remove Orphaned Jobs from the Database

2026-06-23
Read More
Performance

Oracle SQL Patch: Inject Optimizer Hints Without Changing Code

2026-06-13
Read More
0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Demo
Follow Me
  • Email
  • GitHub
  • LinkedIn
  • RSS
  • YouTube

ORA-29548- How to Fix “Java System Class Reported” in Oracle Database

2026-03-0541 Views

INS-06006 – Passwordless SSH Connectivity Not Set Up

2026-02-2626 Views

PRVG-2002- How to Fix “Encountered Error in Copying File” in Oracle RAC

2026-03-0725 Views
Demo
Blogroll
  • oravirt
Execute Step
YouTube LinkedIn RSS
  • Home
  • About
  • Contact
  • RSS
  • English
    • Português (Portuguese (Brazil))
© 2026 ExecuteStep. Designed by ThemeSphere.

Type above and press Enter to search. Press Esc to cancel.

wpDiscuz
Ad Blocker Enabled!
Ad Blocker Enabled!
Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.