Informix Error -591
-591 Invalid default value for column/variable <column-name>/ </column-name>
<variable-name>.The specified default value is the wrong type or is too long for a column or an SPL-routine variable.
To specify a valid default value for a column, use the DEFAULT clause in a CREATE TABLE statement. To specify a valid default value for a variable in an SPL routine, use the DEFAULT clause in a DEFINE statement.
</variable-name>Oninit® Troubleshooting Guidance
Reasons / Common Causes
-591 fires when a DEFAULT clause's value doesn't match the column's (or SPL variable's) type, or
is too long for it — a general type/length mismatch, distinct from the more specific DEFAULT
restrictions covered by -592/-593/-594.
- A
DEFAULTvalue of the wrong type for the column/variable — a string default for a numeric column, or vice versa. - A
DEFAULTstring value too long for the column's declared length (CHAR(n)/VARCHAR(n)). - A
DEFAULTvalue that doesn't parse as a valid literal of the declared type — an improperly formatted date/datetime default, for example.
Solutions / Resolution
- Confirm the
DEFAULTvalue's type and length match the column's (or variable's) declared type, per the official guidance. - For a table column, use the
DEFAULTclause withinCREATE TABLEwith a value matching the column's type:CREATE TABLE orders (order_id INT, status CHAR(10) DEFAULT 'pending'); - For an SPL routine variable, use the
DEFAULTclause within aDEFINEstatement, per the official guidance, with a matching value:DEFINE v_status CHAR(10) DEFAULT 'pending';
Examples
A too-long default
CREATE TABLE orders (order_id INT, status CHAR(5) DEFAULT 'pending');
-- -591: 'pending' (7 chars) exceeds CHAR(5)
Corrected
CREATE TABLE orders (order_id INT, status CHAR(10) DEFAULT 'pending');
Diagnostic Checks
- Compare the
DEFAULTvalue's type and length against the column's/variable's declared type before running the statement.
Related Errors / Related Topics
- -592 — "Cannot specify column to be not null when the default value is null." A related but
more specific
DEFAULT-clause restriction, about a NULL default conflicting with NOT NULL. - -593 — "Cannot specify default value for SERIAL or SERIAL8 or BIGSERIAL column." A related
restriction:
DEFAULTisn't meaningful on an auto-generated serial column at all. - -594 — "Cannot specify non-null default value for TEXT or BYTE column." A related
restriction: only
NULLis a valid default forTEXT/BYTEcolumns.
A general type/length mismatch in a DEFAULT clause — check the value against the column's or
variable's declared type first.