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;