假设我们正在创建数据库“ 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)