ALTER DATABASE [数据库名] { [ DEFAULT ] CHARACTER SET <字符集名> | [ DEFAULT ] COLLATE <校对规则名>}语法说明如下:
mysql> SHOW CREATE DATABASE test_db; +----------+--------------------------------------------------------+ | Database | Create Database | +----------+--------------------------------------------------------+ | test_db | CREATE DATABASE `test_db` /*!40100 DEFAULT CHARACTER SET utf8 */| +----------+--------------------------------------------------------+ 1 row in set (0.05 sec)使用命令行工具将数据库 test_db 的指定字符集修改为 gb2312,默认校对规则修改为 gb2312_unicode_ci,输入 SQL 语句与执行结果如下所示:
mysql> ALTER DATABASE test_db -> DEFAULT CHARACTER SET gb2312 -> DEFAULT COLLATE gb2312_chinese_ci; mysql> SHOW CREATE DATABASE test_db; +----------+--------------------------------------------------------+ | Database | ALTER Database | +----------+--------------------------------------------------------+ | test_db | ALTER DATABASE `test_db` /*!40100 DEFAULT CHARACTER SET gb2312 */| +----------+--------------------------------------------------------+ 1 row in set (0.00 sec)
本文链接:http://task.lmcjl.com/news/13300.html