mysql> select * from good where name = 'a'; +----+------+-------+ | id | name | price | +----+------+-------+ | 3 | a | 100 | | 4 | A | 100 | +----+------+-------+
--把表默认的字符集和所有字符列(CHAR,VARCHAR,TEXT)改为新的字符集: ALTERTABLE tbl_name CONVERTTOCHARACTERSET character_name [COLLATE ...] -- 示例:ALTER TABLE good CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
--修改表的默认字符集: ALTERTABLE tbl_name DEFAULTCHARACTERSET character_name [COLLATE...]; -- 示例:ALTER TABLE good DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- 修改字段的字符集: ALTERTABLE tbl_name CHANGE c_name c_name CHARACTERSET character_name [COLLATE ...]; -- 示例:ALTER TABLE good CHANGE name name VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin; ALTERTABLE good CHANGEnamenameVARCHAR(100) CHARACTERSET utf8 COLLATE utf8_general_ci;
改完之后就OK了
1 2 3 4 5 6
mysql> select * from good where name = 'a'; +----+------+-------+ | id | name | price | +----+------+-------+ | 3 | a | 100 | +----+------+-------+