Take you to the DB2 Character Set and MySql Character Set

Source: Internet
Author: User
Tags mysql import

I believe everyone knows about the DB2 character set. So where is the importance of the DB2 character set for the DB2 database? The following uses MySql and DB2 as an example to explain the character set of the database.

The default character set is used when you create a database or a table,

SQL code in MySql

 
 
  1. CREATE TABLE fuck (   
  2. id varchar(225) DEFAULT NULL  
  3. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 
 
 
  1. CREATE TABLE fuck (  
  2.   id varchar(225) DEFAULT NULL  
  3. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 

SQL code in DB2

 
 
  1. create database ktzpdbusing codeset UTF8 territory cn  
  2. create database ktzpdb  using codeset UTF8 territory cn  

In this way, the character encoding of the database or each table is set to utf8. When we directly use the command window of mysql or db2 to insert Chinese characters, we cannot insert them, this is the code of the command window.

Generally, the character encoding in the Command window should be gbk, so that we can insert and display normally. For example, you can use the configuration file my. ini in Mysql to create a gbk or set names gbk in the window;

In DB2, set db2set DB2CODEPAGE = 1386 in the Command window. When we press Chinese to insert data into the table, the table data is actually stored in utf8, and in the Command window, we can see the Chinese normally due to the gbk setting.

When source d:/insertData. SQL or db2-tf d:/** in db2 :/**. when executing SQL commands such as SQL, the SQL statement must be consistent with the character encoding in the current command window, that is, the above gbk. You can save it as ANSI in notepad. If the SQL encoding is inconsistent, for example, utf8, the gbk on the client cannot identify the utf8 encoding format in the file. It cannot store Chinese or other non-English characters.

In short, if the built-in command window is used, the encoding of the MySql import file must be the same as the character encoding of the command window. Otherwise, the Chinese characters in the data cannot be recognized normally, the DB2 command window is usually set to 1386, that is, GBK. The file is also in ANSI format and will not go wrong!

DB2 update statements for records in the same table

Introduction to DB2 datetime Data Types

Six common DB2 command lines

Four precautions for DB2 Data Import

DB2 Management page size limit

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.