0
votes

DB2 Details:

  • product name : DB2/LINUXX8664
  • version : 10.5.0.5

As per DB2 docs, Maximum length of varchar is 32704 bytes

I tried:

create table t_varchar (c1 varchar(32673));

Got the error:

Error: DB2 SQL Error: SQLCODE=-604, SQLSTATE=42611, SQLERRMC=varchar(32673), DRIVER=4.14.111 SQLState: 42611 ErrorCode: -604

It allowed me to create varchar with max length 32672.

Is this desired behaviour or am I doing something wrong?

Simlilarly, for CHAR I am not able to create table with char(255)

1

1 Answers

3
votes

You left out details on your default tablespace and page size, so I am assuming you are going with the defaults. The maximum row sizes are documented as part of CREATE TABLE. The varchar size you are using is only possible with 32k pages which is not the default page size. So I would expect that error message.

There are also details in terms of value compression, NULL values, etc. that contribute to column size and row size.