MySql table, field, library character set modification and viewing method _ MySQL

Source: Internet
Author: User
This article mainly introduces the modification and viewing methods of character sets of MySql tables, fields, and libraries. This article gives you the modification and viewing statements of MySql tables. For more information, see Modify the database character set:

The code is as follows:


Alter database db_name default character set character_name [COLLATE...];


Change the default character set and all character columns (CHAR, VARCHAR, TEXT) of the table to the new character set:

The code is as follows:


Alter table tbl_name convert to character set character_name [COLLATE...]


For example, alter table logtest convert to character set utf8 COLLATE utf8_general_ci;

Only modify the default character set of the table:

The code is as follows:


Alter table tbl_name default character set character_name [COLLATE...];


For example, alter table logtest default character set utf8 COLLATE utf8_general_ci;

Modify the character set of a field:

The code is as follows:


Alter table tbl_name CHANGE c_name character set character_name [COLLATE...];


For example, alter table logtest CHANGE title VARCHAR (100) character set utf8 COLLATE utf8_general_ci;

View the database code:

The code is as follows:


Show create database db_name;


View the table encoding:

The code is as follows:


Show create table tbl_name;


View the field encoding:

The code is as follows:


Show full columns from tbl_name;

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.