了解 MySQL 数据库的字符集设置
比如我们正在创建一个数据库 “web” −
mysql> SHOW CREATE DATABASE web;
这会产生以下输出显示默认字符集−
+----------+-----------------------------------------------------------------------------------------+ | Database | Create Database | +----------+-----------------------------------------------------------------------------------------+ | web | CREATE DATABASE `web` /*!40100 DEFAULT CHARACTER SET utf8 COLLATEutf8_unicode_ci */ | +----------+-----------------------------------------------------------------------------------------+ 1 row in set (0.03 sec)
如果你想了解来自数据库的特定表的字符集,则使用下面的查询。这里,假设我们在数据库 “web” 中有一个名为 DemoTable 的表 −
mysql> SHOW CREATE table web.DemoTable;
这会产生以下输出显示字符集−
+--------------+----------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +--------------+----------------------------------------------------------------------------------------------------------------------------------+ | DemoTable | CREATE TABLE `DemoTable` (`Value` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci | +--------------+----------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
广告