Informix Error -868
-868 Cannot check constraints on the attaching table.
You cannot attach a table if a check, referential, primary-key, or not null constraint exists on the surviving table.
Drop any check, referential, primary-key, or not null constraint. Then attach the table and if you still want to use the constraint, re-create it.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-868 fires when ALTER FRAGMENT ... ATTACH is attempted while a check, referential,
primary-key, or NOT NULL constraint exists on the surviving table — per the official guidance,
these constraints must be dropped before the attach, then re-created afterward if still needed.
- A check, referential, primary-key, or NOT NULL constraint present on the surviving table, per the official guidance — the direct, only cause; the attach operation can't validate these constraints against the newly-combined data mid-operation.
Solutions / Resolution
- Drop any check, referential, primary-key, or NOT NULL constraint on the surviving table,
per the official guidance:
ALTER TABLE orders DROP CONSTRAINT ck_orders_status; - Attach the table, per the official guidance, once the constraints are cleared:
ALTER FRAGMENT ON TABLE orders ATTACH orders_2025; - Re-create the constraint afterward if still needed, per the official guidance:
ALTER TABLE orders ADD CONSTRAINT CHECK (status IN ('pending','shipped')) CONSTRAINT ck_orders_status; - Inventory every constraint on the surviving table before starting, since more than one
type may be present:
SELECT constrname, constrtype FROM sysconstraints WHERE tabid = (SELECT tabid FROM systables WHERE tabname = 'orders');
Examples
Drop, attach, re-create
ALTER TABLE orders DROP CONSTRAINT ck_orders_status;
ALTER FRAGMENT ON TABLE orders ATTACH orders_2025;
ALTER TABLE orders ADD CONSTRAINT
CHECK (status IN ('pending','shipped')) CONSTRAINT ck_orders_status;
Diagnostic Checks
- Query
sysconstraintsfor every constraint on the surviving table, and drop each one of the four affected types before attempting the attach.
Related Errors / Related Topics
- -866 — "Cannot attach tables that contain serial fields." Same general family of
ATTACH-prerequisite restrictions — drop or modify the blocking structure first. - -864 — "Cannot attach a table with rowids." Same family, for ROWID specifically.
Drop check, referential, primary-key, and NOT NULL constraints from the surviving table first, attach, then re-create the constraints afterward if still needed.