Informix Error -24122: Column not specified for hash/hybrid fragmentation and there is no primary key for the table.
Cause and resolution
Column not specified for hash/hybrid fragmentation and there is no primary key for the table.
When a table is created with hash or hybrid fragmentation, if no column is specified as the hash key in hash or hybrid fragmentation, then the database server uses the primary key for the table as the hash key. This error occurred because there is no primary key for the table and no hash column was specified.
For example, the following statement will get error -24122:
create table tab ( c1 int, c1 int, c2 char(10) ) fragment by hybrid expression c1 < 1000 in db1, remainder in db2; There are two ways to fix this statement. 1). Add a hybrid column: create table tab1 ( c1 int, c2 char(10) ) fragment by hybrid(c2) expression c1 < 1000 in db1, remainder in db2; 2). Add a primary key: create table tab2 ( c1 int primary key, c2 char(10) ) fragment by hybrid expression c1 < 1000 in db1, remainder in db2;
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-24122 fires when a table created with hash or hybrid fragmentation names no explicit hash column and the table also has no primary key — per the official guidance, the server normally falls back to the primary key as the hash key when no column is specified.
- No hash column specified in a
FRAGMENT BY HASH/HYBRIDclause, combined with no primary key on the table, per the official guidance — the direct, only cause.
Solutions / Resolution
- Add an explicit hybrid/hash column to the fragmentation clause, per the official guidance, or
- Add a primary key to the table, per the official guidance, so the server has a hash key to fall back on.
Examples
Hybrid fragmentation with no primary key or explicit column
CREATE TABLE tab (c1 INT, c2 CHAR(10))
FRAGMENT BY HYBRID EXPRESSION
c1 < 1000 IN db1,
REMAINDER IN db2;
-- -24122: no primary key, and no hybrid column named
Corrected — naming an explicit hybrid column
CREATE TABLE tab (c1 INT, c2 CHAR(10))
FRAGMENT BY HYBRID(c2) EXPRESSION
c1 < 1000 IN db1,
REMAINDER IN db2;
Diagnostic Checks
- Check whether the table has a primary key, and whether the
FRAGMENT BY HASH/HYBRIDclause names an explicit column, and add whichever is missing.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -24122 in this set yet.
Hash/hybrid fragmentation had neither an explicit hash column nor a primary key to fall back on — add one or the other.