Informix Error -536
-536 Number of columns in child constraint does not match number of
cols in parent constraint.The number of referencing columns (child key) does not match the number of referenced columns (parent key) in the referential constraint. Check that a one-to-one relationship exists between referenced and referencing columns.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-536 fires when a FOREIGN KEY constraint's referencing (child) column list has a different
number of columns than the referenced (parent) key it points to — a composite foreign key must
map one-to-one, column-for-column, onto the parent's key.
- A composite foreign key listing fewer or more columns than the parent's primary/unique key — the direct, only cause.
- A schema change that added or removed a column from the parent key, without updating foreign keys elsewhere that reference it.
- Copy-pasted
FOREIGN KEYDDL from a different relationship, where the column count happened to differ from the parent key actually being referenced here.
Solutions / Resolution
- Check that a one-to-one relationship exists between referenced and referencing columns, per the official guidance, by comparing the two column lists directly.
- Add or remove columns from the child key list so its count matches the parent key's column count exactly.
- Confirm the parent key's actual column list before rewriting the foreign key, in case a
schema change altered it.
sysindexes.part1throughpart16hold thecolnoof each key part (negative for descending order) for the index backing the parent constraint:
then match each non-nullSELECT i.part1, i.part2, i.part3 FROM sysconstraints k, sysindexes i WHERE k.idxname = i.idxname AND k.constrname = 'parent_key_constraint_name';partN(its absolute value) againstsyscolumns.colnofor the sametabidto get the actual column names.
Examples
Mismatched column counts
CREATE TABLE orders (order_id INT, region_id INT, PRIMARY KEY (order_id, region_id));
CREATE TABLE order_items (
item_id INT,
order_id INT,
FOREIGN KEY (order_id) REFERENCES orders(order_id, region_id)
);
-- -536: child key has 1 column, parent key has 2
Corrected
CREATE TABLE order_items (
item_id INT,
order_id INT,
region_id INT,
FOREIGN KEY (order_id, region_id) REFERENCES orders(order_id, region_id)
);
Diagnostic Checks
- Count the columns in the
FOREIGN KEY (...)list and the parent'sREFERENCES table(...)list side by side before running theCREATE TABLE/ALTER TABLEstatement.
Related Errors / Related Topics
- -537 — "Constraint column column-name not found in table." A related but distinct constraint-definition error: a named column that doesn't exist at all, rather than a count mismatch between two existing column lists.
A column-count mismatch between the child and parent key lists — recount both sides against the parent's actual key definition.