Long varchar type in DB2

Source: Internet
Author: User

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;

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.