ORA-00001: unique constraint (SCHEMA.PK_X) violated
An insert/update duplicated a value in a unique or primary key constraint.
Seen on:
SQL
Meaning
Common when sequences fall behind manually inserted ids or seeds run twice.
Common causes
- Duplicate value
- Sequence behind existing max(id)
- Re-run seeds
⚡ Quick fix
- Use MERGE for upserts
- Advance the sequence past max(id)
- Handle as "already exists"
Detailed fix by platform
SQL
ALTER SEQUENCE orders_seq RESTART START WITH 100001; -- Oracle 18c+
How to diagnose
- Constraint — Which one?
- Sequence — Behind the data?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026