DB2 database UTF-8 Character set for 3 bytes __ Database

Source: Internet
Author: User
Tags db2
A problem was found when using remote federated database objects: 1. Connect to remote database query data

Select Jybs_mx
From Mq_agntinfo
Fetch 1 Rows only
with ur;


Results

Jybs_mx
0 Member Demotion


2, connect the local database, through the Remote Federated database object query the same table

It turned out to be

Jybs_mx
0 Member Drop

Compared with the remote database, one Chinese character is missing.

3, through the following SQL statements

Select Jybs_mx,length (Trim (JYBS_MX))
From Mq_agntinfo
Fetch 1 Rows only
with ur;

Connection remote database query results are:

JYBS_MX 2
0 Member Downgrade 9

The result of connecting to a local database query is:

JYBS_MX 2
0 members down 10

The local database processed 1 Chinese characters as 3 bytes, while the remote database processed 1 Chinese characters as 2 bytes, while the field JYBS_MX data type is varchar (10) and more than half was truncated.

4. View the character set of remote database and local database, respectively

The original character set of the remote database is "GBK", and the local database's character set is "UTF-8"

Conclusion: When DB2 database character set is UTF-8, 1 Chinese characters account for 3 bytes

5, the simple solution:

The local nickname corresponding to the field type length, the problem is resolved.

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.