Informix Error -676
-676 Invalid check constraint column.
A check constraint that is specified at the column level can reference only that column. To specify a check constraint that spans more than one column, specify the check constraint at the table level. You cannot create a check constraint for columns across tables.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-676 fires when a column-level CHECK constraint's expression references a column other than the
one it's attached to — per the official guidance, a column-level check can only reference that
same column; anything spanning multiple columns needs to be a table-level constraint instead.
- A column-level
CHECKreferencing a different column, per the official guidance — the direct, only cause. - A check genuinely needing to compare two columns, written at the column level out of habit rather than being moved to the table level where multi-column checks belong.
- A check attempting to reference a column in a different table, per the official guidance's closing note — this isn't supported at either the column or table level; cross-table constraints need a trigger instead.
Solutions / Resolution
- Move a multi-column check to the table level, per the official guidance, rather than
attaching it to a single column:
CREATE TABLE orders ( order_date DATE, ship_date DATE, CHECK (ship_date >= order_date) ); - For a genuinely single-column check, confirm the expression only references that column.
- For a check that would need to span tables, use a trigger instead, per the official guidance — check constraints (column- or table-level) can't reference another table at all.
Examples
The disallowed column-level cross-reference
CREATE TABLE orders (
order_date DATE CHECK (ship_date >= order_date),
ship_date DATE
);
-- -676: order_date's column-level check references ship_date
Corrected — a table-level check
CREATE TABLE orders (
order_date DATE,
ship_date DATE,
CHECK (ship_date >= order_date)
);
Diagnostic Checks
- Check whether a column-level
CHECK's expression references only that column, and move it to the table level if it needs to reference others.
Related Errors / Related Topics
- -677 — "Check constraint cannot contain subqueries or procedures." A related
CHECKrestriction, about what kinds of expressions are allowed regardless of column vs. table level. - -678 — "Invalid subscript for column column-name in check constraint." A related
CHECKrestriction, about subscript bounds rather than column scope.
Column-level checks can only reference their own column — move a multi-column check to the table level.