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;編碼

此處寫utf8_general_ci有時候會報錯,直接寫utf8便可spa

alter table logtest convert to character set  utf8;ci

只是修改表的默認字符集:

ALTER TABLE tbl_name DEFAULT CHARACTER SET character_name [COLLATE…]; 
如:ALTER TABLE logtest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;it

修改字段的字符集:

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;table

查看數據庫編碼:

SHOW CREATE DATABASE db_name;test

查看錶編碼:

SHOW CREATE TABLE tbl_name;數據

查看字段編碼:

SHOW FULL COLUMNS FROM tbl_name;db

相關文章
相關標籤/搜索