Assuming we are creating a database "network" -
mysql> SHOW CREATE DATABASE web;
This will produce the following output while displaying the default character set -
+----------+-----------------------------------------------------------------------------------------+ | Database | Create Database | +----------+-----------------------------------------------------------------------------------------+ | web | CREATE DATABASE `web` /*!40100 DEFAULT CHARACTER SET utf8 COLLATEutf8_unicode_ci */ | +----------+-----------------------------------------------------------------------------------------+ 1 row in set (0.03 sec)
If you To find out the character set of a specific table in the database, use the following query. Here, assume we have a table named DemoTable in database "web" -
mysql> SHOW CREATE table web.DemoTable;
This will produce the following output showing the character set -
+--------------+----------------------------------------------------------------------------------------------------------------------------------+ | 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)
The above is the detailed content of Determine what the character set of the MySQL database is set to. For more information, please follow other related articles on the PHP Chinese website!