Informix Error -26018: Table %s has a referential key constraint and is not empty.
Cause and resolution
Table %s has a referential key constraint and is not empty.
The table being truncated has a unique or primary key that is referenced by the above table.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-26018 fires when TRUNCATE TABLE is attempted on a table whose unique/primary key is
referenced by another, non-empty table — per the official guidance.
- The table being truncated has a unique/primary key referenced by another table, per the official guidance — the direct, only cause; truncating it would orphan the referencing rows.
Solutions / Resolution
- Remove or reassign the referencing rows in the other table first, per the official guidance's implication, or truncate that table too, before truncating this one.
Examples
Truncating a referenced table
TRUNCATE TABLE customers;
-- -26018: orders.customer_id references customers, and orders isn't empty
Diagnostic Checks
- Check
sysreferencesfor foreign keys referencing this table's primary/unique key, and confirm the referencing tables are empty before truncating.
Related Errors / Related Topics
- -26020 — "Truncating a table with delete trigger requires ALTER privilege." A related
TRUNCATE TABLErestriction, on delete triggers and privilege rather than referential integrity. - -26021 — "No operations allowed after truncate or online alter fragment in a
transaction." A related
TRUNCATE TABLErestriction, on subsequent transaction operations rather than referential integrity.
TRUNCATE TABLE was attempted on a table referenced by another, non-empty table's foreign
key — empty or truncate the referencing table first.