MySql表、字段、庫的字符集修正及檢查辦法。本站提示廣大學習愛好者:(MySql表、字段、庫的字符集修正及檢查辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是MySql表、字段、庫的字符集修正及檢查辦法正文
修正數據庫字符集:
ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...];
把表默許的字符集和一切字符列(CHAR,VARCHAR,TEXT)改成新的字符集:
ALTER TABLE tbl_name CONVERT TO CHARACTER SET character_name [COLLATE ...]
如:ALTER TABLE logtest CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
只是修正表的默許字符集:
ALTER TABLE tbl_name DEFAULT CHARACTER SET character_name [COLLATE...];
如:ALTER TABLE logtest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
修正字段的字符集:
ALTER TABLE tbl_name CHANGE c_name c_name CHARACTER SET character_name [COLLATE ...];
如:ALTER TABLE logtest CHANGE title title VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;
檢查數據庫編碼:
SHOW CREATE DATABASE db_name;
檢查表編碼:
SHOW CREATE TABLE tbl_name;
檢查字段編碼:
SHOW FULL COLUMNS FROM tbl_name;