Informix Error -551
-551 The constraint contains too many columns.
The total number of columns listed in a UNIQUE, PRIMARY KEY, or FOREIGN KEY clause is limited. The limit depends on the database server in use, but all database servers support eight columns. The limit is the same as the restriction on the number of columns in a composite index. For additional information, refer to the CREATE INDEX statement in the IBM Informix Guide to SQL: Syntax.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-551 is the column-count half of the same composite-index limit behind -517/-550,
applied specifically to the column count of a UNIQUE, PRIMARY KEY, or FOREIGN KEY clause —
every Informix server supports at least 8 columns per constraint, per the official guidance, with
the exact ceiling depending on the server in use (up to 16 on IBM Informix Dynamic Server/
Universal Server).
- A composite
UNIQUE/PRIMARY KEY/FOREIGN KEYlisting more columns than the platform allows — the direct, only cause. - A schema evolved incrementally, adding columns to an existing composite key one at a time
over successive
ALTER TABLEstatements, until it crossed the limit without anyone reviewing the total count.
Solutions / Resolution
- Reduce the number of columns in the constraint, per the official guidance, to fit within the platform's limit (at minimum 8, per the official guidance's guaranteed floor).
- Consult the
CREATE INDEXstatement's documented limits for the exact ceiling on the server in use, per the official guidance's own pointer, since it varies by product/platform. - Consider whether a narrower key (fewer, more selective columns) achieves the same uniqueness/reference guarantee, rather than listing every available column.
Examples
Exceeding the limit
CREATE TABLE wide_key_table (
c1 INT, c2 INT, c3 INT, c4 INT, c5 INT, c6 INT, c7 INT, c8 INT, c9 INT,
UNIQUE (c1, c2, c3, c4, c5, c6, c7, c8, c9)
);
-- -551: 9 columns exceeds this platform's constraint column-count limit
Narrowed to fit
CREATE TABLE wide_key_table (
c1 INT, c2 INT, c3 INT, c4 INT, c5 INT, c6 INT, c7 INT, c8 INT, c9 INT,
UNIQUE (c1, c2, c3, c4, c5, c6, c7, c8)
);
Diagnostic Checks
- Count the columns in the constraint's column list against the platform's documented
CREATE INDEXcolumn-count limit.
Related Errors / Related Topics
- -517 — "The total size of the index is too large or too many parts in index." The same
underlying composite-index limit, hit via
CREATE INDEXdirectly. - -550 — "Total length of columns in constraint is too long." The byte-width half of the same limit family, rather than the column-count half.
The column-count half of the same composite-index limit as -517/-550 — narrow the constraint's column list to fit the platform's ceiling.