Informix Error -362
-362 Can have only one column of serial/(serial8 or bigserial) type.
A table can have at most only one column of type SERIAL and one column of type SERIAL8/BIGSERIAL. You are attempting to add a second column of type SERIAL or SERIAL8/BIGSERIAL, or you are attempting to create a table with more than one column of either type. If you intended to have a foreign key (that is, a column that refers to a SERIAL or SERIAL8/BIGSERIAL column in a different table), the data type of the column in this table should be INTEGER or INT8 or BIGINT.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-362 is a per-table cardinality limit: a table can have at most one SERIAL column and,
separately, at most one SERIAL8/BIGSERIAL column — not two of the same auto-incrementing
type. This trips people up most often when a foreign key column is mistakenly declared as
SERIAL too, since a foreign key referencing a SERIAL primary key should use a plain integer
type instead.
- A
CREATE TABLE/ALTER TABLE ADDattempting a secondSERIAL(or secondSERIAL8/BIGSERIAL) column on the same table — the direct cause. - Declaring a foreign key column as
SERIALwhen it should beINTEGER/INT8/BIGINT— a foreign key only needs to hold values matching the referencedSERIALcolumn's generated numbers, not generate its own. - Copy-pasted column definitions carried over from the primary key column's
SERIALdeclaration into a different column that shouldn't auto-increment.
Solutions / Resolution
- Use
INTEGER,INT8, orBIGINTfor a foreign key referencing aSERIALcolumn, per the official guidance — neverSERIALitself on the referencing side. - Confirm only one column is intended to auto-generate values per table, and use a
sequence-based or application-managed value for any additional "unique identifier" columns
instead of a second
SERIAL.
Examples
A foreign key mistakenly declared as SERIAL
CREATE TABLE customers (
customer_id SERIAL PRIMARY KEY,
name VARCHAR(50)
);
CREATE TABLE orders (
order_id SERIAL PRIMARY KEY,
customer_id SERIAL REFERENCES customers(customer_id)
);
-- -362: orders already has order_id as SERIAL
Fix — use a plain integer type for the foreign key column:
CREATE TABLE orders (
order_id SERIAL PRIMARY KEY,
customer_id INTEGER REFERENCES customers(customer_id)
);
Diagnostic Checks
- Review the table's column definitions for more than one
SERIALcolumn, or more than oneSERIAL8/BIGSERIALcolumn. - For any foreign key column, confirm it uses a plain integer type, not
SERIAL, regardless of what type the referenced column uses.
Related Errors / Related Topics
- -356 — "Data type of the referencing and referenced columns do not match." A closely
related concern — the correct type for a foreign key column referencing a
SERIALcolumn is a plain integer type, which also needs to match on both sides. - -328 — "Column column-name already exists in table." Another
ALTER TABLE ADD-time restriction, though about naming rather than type cardinality.
A foreign key referencing a SERIAL column should always be declared as a plain INTEGER/
INT8/BIGINT, never SERIAL itself — that's the most common way this limit gets hit.