Problem solve Get help with specific problems with your technologies, process and projects.

The maximum length of a VARCHAR item

What is the maximum length of a VARCHAR item?

The maximum length of a VARCHAR column is dependent upon the page size used by the table size for the table having the VARCHAR column. For 4K pages -- usually the bulk of your table spaces -- the maximum VARCHAR column is 4046 bytes. For 8K pages it is 8128 bytes, for 16K pages it is 16320 bytes and for 32K pages it is 32704 bytes. These maximum record sizes indicate the maximum length of a VARCHAR column if that column is the only column in the table. If there are other columns, of course, the maximum size of the VARCHAR is reduced by the amount of space required for the other columns. Of course, you have to keep in mind that any VARCHAR defined to be greater than 255 defines a long string column. And, there are restrictions on how long string columns can be used. For example, they cannot be used in GROUP BY or ORDER BY clauses, a CREATE INDEX, a SELECT DISTINCT or within a subselect of a UNION without the ALL key word.

Editor's note: Do you agree with this expert's response? If you have more to share, post it in one of our [email protected]/search390>discussion forums.

Dig Deeper on IBM DB2 management