In DB2, the long varchar and VARCHAR Data Types in DB2 are used to store LONG texts, but their usage is quite different. Like normal data types, VARCHAR uses bufferpool, which is subject to the maximum bufferpool page size when creating a table. long varchar, like LOB data, has a separate storage area, no bufferpool is required. Therefore, a large bufferpool is not required when creating a table. when accessing the data, you can directly perform disk I/O operations to access the data, which is faster. However, the use of long varchar data types is also limited and cannot be used in the following statements: distinctgroup byorder bybetween/INLIKE subquery the maximum length of data allowed by long varchar in the internal column function is 32700 bytes, VARCHAR can contain up to 32672 bytes. Operations on long varchar in CLP and CE may not be expected. For example, if you use the following statement for long varchar columns with a length greater than 8192 bytes, truncation will occur and no warning is given.
SELECT longvarchar FROM table;
The following statement is not safe because the statement fails if the column length exceeds the maximum length 32672 allowed by VARCHAR.
Select varchar (longvarchar) FROM table;
The safe syntax is to use the expression CAST.
Select cast (langvarchar as varchar (32672) FROM table;