SHOW CREATE DATABASE

SHOW CREATE DATABASE is used to show the exact SQL statement for re-creating an existing database. SHOW CREATE SCHEMA is a synonym for it.

Synopsis

ShowCreateDatabaseStmt:

ShowCreateDatabaseStmt

SHOW CREATE DATABASE - 图1

  1. ShowCreateDatabaseStmt ::=
  2. "SHOW" "CREATE" ("DATABASE" | "SCHEMA") ("IF" "NOT" "EXISTS")? DBName

Examples

  1. CREATE DATABASE test;
  1. Query OK, 0 rows affected (0.12 sec)
  1. SHOW CREATE DATABASE test;
  1. +----------+------------------------------------------------------------------+
  2. | Database | Create Database |
  3. +----------+------------------------------------------------------------------+
  4. | test | CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
  5. +----------+------------------------------------------------------------------+
  6. 1 row in set (0.00 sec)
  1. SHOW CREATE SCHEMA IF NOT EXISTS test;
  1. +----------+-------------------------------------------------------------------------------------------+
  2. | Database | Create Database |
  3. +----------+-------------------------------------------------------------------------------------------+
  4. | test | CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
  5. +----------+-------------------------------------------------------------------------------------------+
  6. 1 row in set (0.00 sec)

MySQL compatibility

SHOW CREATE DATABASE is expected to be fully compatible with MySQL. If you find any compatibility differences, you can report a bug.

See also