Informix Error -594
-594 Cannot specify non-null default value for TEXT or BYTE column.
This CREATE or ALTER TABLE statement specifies that a column has a data type of BYTE or TEXT. It also has a DEFAULT clause for the column that specifies something other than NULL. You can only designate the default value NULL for columns of TEXT or BYTE data type.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-594 fires when a TEXT or BYTE (simple large object) column is given a DEFAULT clause
specifying anything other than NULL — per the official guidance, NULL is the only value these
two types can take as a default.
- A
DEFAULTclause on aTEXT/BYTEcolumn specifying a literal value, per the official guidance — the direct, only cause. - DDL copy-pasted from a character or binary-string column's definition (which could
legitimately default to a specific literal) into a
TEXT/BYTEcolumn's definition. - A misunderstanding of
TEXT/BYTEstorage — these types store large data via a separate mechanism from ordinary column storage, which is why a literal default isn't supported the way it is forCHAR/VARCHAR.
Solutions / Resolution
- Change the default to
NULL, per the official guidance — the only value these types accept as a default, or remove theDEFAULTclause entirely (which has the same effect). - Populate the column explicitly on insert if a non-NULL initial value is genuinely needed,
rather than relying on a
DEFAULTclause.
Examples
The disallowed attempt
CREATE TABLE documents (doc_id INT, content TEXT DEFAULT 'placeholder');
-- -594: TEXT columns can only default to NULL
Corrected
CREATE TABLE documents (doc_id INT, content TEXT DEFAULT NULL);
Or populate explicitly on insert instead of relying on a default
INSERT INTO documents (doc_id, content) VALUES (1, 'actual content');
Diagnostic Checks
- Scan
TEXT/BYTEcolumn definitions for aDEFAULTclause specifying anything other thanNULL, and change it toNULLor remove the clause.
Related Errors / Related Topics
- -591 — "Invalid default value for column/variable column-name/variable-name." The more
general
DEFAULT-clause error family this specific TEXT/BYTE restriction belongs to.
TEXT/BYTE columns can only default to NULL — populate a non-NULL initial value explicitly
on insert instead.