ORA-00001 🗃️ SQL

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

  1. Use MERGE for upserts
  2. Advance the sequence past max(id)
  3. Handle as "already exists"

Detailed fix by platform

SQL

  1. ALTER SEQUENCE orders_seq RESTART START WITH 100001; -- Oracle 18c+

How to diagnose

  1. Constraint — Which one?
  2. 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.