To modify the database character set:
Copy Code code as follows:
ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...];
change the table default character set and all character columns (Char,varchar,text) to the new character set:
Copy Code code as follows:
ALTER TABLE tbl_name CONVERT to CHARACTER SET character_name [COLLATE ...]
such as: ALTER TABLE logtest CONVERT to CHARACTER SET UTF8 COLLATE utf8_general_ci;
Just modify the default character set for the table:
Copy Code code as follows:
ALTER TABLE tbl_name DEFAULT CHARACTER SET character_name [COLLATE ...];
such as: ALTER TABLE logtest DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
To modify the character set of a field:
Copy Code code as follows:
ALTER TABLE tbl_name Change c_name c_name CHARACTER SET character_name [COLLATE ...];
such as: ALTER TABLE logtest Change title title VARCHAR (m) CHARACTER SET UTF8 COLLATE utf8_general_ci;
To view the database encoding:
Copy Code code as follows:
Show CREATE DATABASE db_name;
View Table encoding:
Copy Code code as follows:
Show CREATE TABLE tbl_name;
To View the field encoding:
Copy Code code as follows:
Show full COLUMNS from Tbl_name;