SHOW CREATE DATABASE

SHOW CREATE DATABASE 语句用于显示用 SQL 重新创建已有库的确切语句。SHOW CREATE SCHEMA 与其同义。

语法图

ShowCreateDatabaseStmt:

ShowCreateDatabaseStmt

SHOW CREATE DATABASE - 图1

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

示例

  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 兼容性

SHOW CREATE DATABASE 语句与 MySQL 完全兼容。如发现任何兼容性差异,请在 GitHub 上提交 issue

另请参阅