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 .VO7aaqqaAFk.0@/search390>discussion forums.
Dig Deeper on IBM DB2 management
Related Q&A from Craig S. Mullins
To export data from a DB2 table to a flat file, you need to run an export specifying the proper file format. The export utility exports data from a ... Continue Reading
Craig Mullins recommends two specific resources for learning how to create and support Binary Large Objects (BLOB) in DB2. Continue Reading
Craig Mullins explains various definitions of a data mart and sheds some light on the complexity of its relation to a data warehouse. Continue Reading