Informix Error -296
-296 Referenced table table-name not available.
The table that is specified in a referential constraint does not exist or is not accessible. Check the accompanying ISAM error code for more information.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-296 fires when a REFERENCES clause names a table that Informix can't actually get to — not
just "doesn't exist," but potentially locked, dropped, or otherwise inaccessible. The official
text notes an accompanying ISAM error code may narrow this down further.
- The referenced table name is misspelled or doesn't exist in the target database.
- The referenced table exists but has been dropped or renamed since the constraint definition was written (a stale DDL script, or a schema migration applied out of order).
- The referenced table exists but the current user lacks the privileges to access it — Informix can't validate the constraint against a table it can't read.
- The referenced table is locked or otherwise unavailable at constraint-creation time (an exclusive lock held by another session, a table space offline).
- Table creation order in a migration script — the referencing table's
CREATE TABLEruns before the referenced table has actually been created.
Solutions / Resolution
- Check the accompanying ISAM error code first, per the official guidance — it usually points directly at the underlying cause (not found vs. locked vs. permission).
- Verify the referenced table's exact name and that it exists in the same database:
SELECT tabname FROM systables WHERE tabname = 'parent_table'; - Confirm the current user has at least
SELECT(orREFERENCES) privilege on the referenced table. - Reorder DDL scripts so referenced (parent) tables are created before the tables that reference them.
- If the table appears locked, retry after the holding session releases it, or investigate what's holding the lock.
Examples
Wrong creation order in a migration script
-- Wrong order: orders references customers, but customers
-- hasn't been created yet
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER REFERENCES customers(customer_id)
);
-- -296: customers doesn't exist yet
CREATE TABLE customers (
customer_id INTEGER PRIMARY KEY,
name VARCHAR(50)
);
Fix — create the referenced table first:
CREATE TABLE customers (
customer_id INTEGER PRIMARY KEY,
name VARCHAR(50)
);
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER REFERENCES customers(customer_id)
);
Checking privileges on the referenced table
SELECT tabname, owner FROM systables WHERE tabname = 'customers';
-- confirm the referencing user has SELECT/REFERENCES on it
GRANT REFERENCES ON customers TO app_user;
Diagnostic Checks
- Read the accompanying ISAM error code in the full error message for the specific underlying reason.
- Confirm the referenced table exists in the same database and is spelled correctly.
- Confirm privileges on the referenced table for the user running the DDL.
- Review DDL script ordering if this is happening during a migration or schema-build run.
Related Errors / Related Topics
- -295 — "Referenced and referencing tables have to be in the same database." A related referential-integrity restriction — this error assumes the databases already match but the table itself still isn't reachable.
- -201 — "A syntax error has occurred." The general SQL-parsing-error family this fits into.
Check the accompanying ISAM error code first — it's the fastest way to tell whether the referenced table is simply missing, misspelled, locked, or a privilege problem.