I am looking for alternative to create index on long column:
create table line
(
field_key integer not null,
value varchar(4000),
...
);
create index key_value_idx on line (field_key, value);
results DB2 SQL Error: SQLCODE=-614, SQLSTATE=54008
. Documentation says: The sum of the stored lengths of the specified columns must not be greater than 1024
. For such cases in MySQL there is syntax:
create index key_value_idx on line (field_key, value(1000));
and HSQLDB just works without any limitations.
What is the analogue for DB2?
Best Answer
Here is the information on the CREATE INDEX statement for DB2. You may also want to check these links on designing indexes and space requirements for indexes as they also deal with your question on what factors into index page space.
Based on the last link it would seem to me that the page size for the index would be your column lengths + the index overhead. This may take you beyond the page size for your table. (Maybe that is what is happening here.) You could also try to place your table in a bigger tablespace. It may place the index in a bigger page size as well.