Informix Error -356
-356 Data type of the referencing and referenced columns do not match.
The data types of the columns in the child constraint must be identical to those in the parent constraint.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-356 is a foreign-key setup restriction: the referencing (child) column's data type must exactly match the referenced (parent) column's data type — Informix doesn't implicitly convert between even closely related types for the purposes of enforcing a foreign key relationship.
- A referencing column declared with a different type than the referenced column — e.g. the
child uses
INTEGERwhile the parent's key isSERIAL, or one usesVARCHAR(20)while the other usesCHAR(20). - A schema change to one side of the relationship (widening/narrowing a column, or changing its base type) without updating the other side to match.
- Copy-pasted table definitions where a column's type was adjusted on one table but not propagated to the corresponding foreign key column on another.
- Confusing "compatible for comparison" with "identical for a foreign key" — types that would compare or join fine in an ordinary query aren't necessarily acceptable for this constraint.
Solutions / Resolution
- Match the referencing column's data type exactly to the referenced column's data type, per the official guidance.
- Check both columns' definitions side by side before defining the constraint:
SELECT c.colname, t2.name AS type_name FROM syscolumns c, systypes t2, systables t WHERE t.tabname IN ('orders', 'customers') AND c.tabid = t.tabid AND c.coltype = t2.type; - If a schema change on one side is unavoidable, propagate the same change to the other side of every foreign key relationship involving that column.
Examples
Mismatched types between parent and child
CREATE TABLE customers (
customer_id SERIAL PRIMARY KEY
);
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id VARCHAR(10) REFERENCES customers(customer_id)
);
-- -356: customer_id is SERIAL (effectively INTEGER) on the
-- parent but VARCHAR(10) on the child
Fix — match the types exactly:
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER REFERENCES customers(customer_id)
);
Diagnostic Checks
- Compare the exact declared types of both columns in
syscolumns/systypes— not just whether they "look" compatible. - Check for a recent type change on either the parent or child table if a previously-valid constraint now fails during a schema migration.
Related Errors / Related Topics
- -295 — "Referenced and referencing tables have to be in the same database." Another foreign-key setup restriction in the same general family.
- -297 — "Cannot find unique constraint or primary key on referenced table table-name." Another constraint-setup error in the same family.
Match column types exactly on both sides of a foreign key relationship — "compatible for comparison" in an ordinary query isn't the same bar as what a foreign key constraint requires.