What is the maximum length of a VARCHAR item?
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
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
Our expert suggests that the best way to pass the SAP BW exam is to have hands-on job experience. But that's not all he has to say about ...continue reading
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
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.