Informix Error -26454: Cannot specify both a PRIMARY KEY constraint and a NULL constraint for the same column.
Cause and resolution
Cannot specify both a PRIMARY KEY constraint and a NULL constraint for the same column.
The database server issues this error when the CREATE TABLE or ALTER TABLE statement attempts to define a table schema that includes a column definition with contradictory specifications regarding NULL values. - The PRIMARY KEY constraint prevents the database server from storing NULL values in this column. - The NULL constraint allows the database server store NULL values in this column.
To avoid this error, revise the column definition so that it does not include both PRIMARY KEY and NULL specifications on the same column. - If you want this column to be the primary key of this table, you must drop the NULL specification in the column definition. - If you want to allow NULL values in this column, you must drop the PRIMARY KEY specification in the column definition.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-26454 fires when a column definition specifies both PRIMARY KEY and NULL — per the
official guidance.
- A column defined with both
PRIMARY KEY(which prevents nulls) andNULL(which allows them), per the official guidance — the direct, only cause; contradictory.
Solutions / Resolution
- To make the column the primary key, drop the
NULLspecification, per the official guidance, or - To allow nulls, drop the
PRIMARY KEYspecification, per the official guidance.
Examples
A contradictory column definition
CREATE TABLE orders (order_id INT PRIMARY KEY NULL);
-- -26454: PRIMARY KEY and NULL are contradictory
Corrected
CREATE TABLE orders (order_id INT PRIMARY KEY);
Diagnostic Checks
- Check the column definition for both
PRIMARY KEYandNULL, and remove one.
Related Errors / Related Topics
- -26455 — "Cannot specify both a NOT NULL constraint and a NULL constraint for the
same column." The same class of contradictory-nullability error, for
NOT NULL/NULLrather thanPRIMARY KEY/NULL.
A column definition specified both PRIMARY KEY and NULL — remove one.