背景: 当数据库的建库字符集和表不一样时,在库下针对表创建存储过程可能导致全表扫描 如下例: drop database if exists xx1; drop database if exists xx2; create database xx1 character set utf8; create database xx2 character set gbk; 然后分别在xx1 和 xx2下执行: CREATE TABLE t1 ( `col1` varchar(10) NOT NULL
mysql修改表.字段.库的字符集 修改数据库字符集: ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...]; 把表默认的字符集和所有字符列(CHAR,VARCHAR,TEXT)改为新的字符集: ALTER TABLE test CONVERT TO CHARACTER SET character_name [COLLATE ...] 如:ALTER TABLE test CONVERT TO CHAR