# ORA-00001: unique constraint (SCHEMA.PK_X) violated

**Code:** `ORA-00001` · **Category:** SQL · **Seen on:** SQL

An insert/update duplicated a value in a unique or primary key constraint.

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/sql/ora-00001-unique-constraint-violated)
