Informix Error -515: Constraint constraint-name has already been dropped.
Cause and resolution
Constraint constraint-name has already been dropped.
You are trying to drop a constraint that has already been dropped in the same ALTER TABLE statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-515 is specifically about dropping the same constraint twice within a single ALTER TABLE
statement — not about a constraint that was dropped in some earlier, separate statement.
- A single
ALTER TABLEnaming the same constraint in more than oneDROP CONSTRAINTclause — per the official guidance, the direct, only cause. - A constraint referenced by two different names that turn out to be the same constraint — for example, an explicit name and a system-generated name both pointing at the same underlying constraint, both listed for dropping in the same statement.
- Generated DDL that lists constraints to drop from a stale or duplicated source list,
producing a repeated
DROP CONSTRAINTentry in one statement.
Solutions / Resolution
- Remove the duplicate
DROP CONSTRAINTclause from theALTER TABLEstatement, keeping only one instance per constraint name. - Confirm two differently-named clauses don't actually reference the same constraint, by
checking
sysconstraintsbefore building the statement:SELECT constrname, constrid FROM sysconstraints WHERE tabid = (SELECT tabid FROM systables WHERE tabname = 'orders'); - Deduplicate any generated list of constraints to drop before assembling the
ALTER TABLEstatement, if the list is built programmatically.
Examples
The disallowed duplicate
ALTER TABLE orders
DROP CONSTRAINT ck_orders_status,
DROP CONSTRAINT ck_orders_status;
-- -515: ck_orders_status named twice in the same statement
Corrected
ALTER TABLE orders
DROP CONSTRAINT ck_orders_status;
Diagnostic Checks
- Scan the
ALTER TABLEstatement'sDROP CONSTRAINTclauses for repeated names before running it. - Query
sysconstraintsto resolve constraint names to IDs when two clauses use different names, to rule out both pointing at the same underlying constraint.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -515 in this set yet.
Scoped to a single statement: the same constraint named twice in one ALTER TABLE's drop
clauses, not a constraint dropped by an earlier, separate statement.