SHOW CREATE DATABASE

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

语法图

ShowCreateDatabaseStmt:

ShowCreateDatabaseStmt
SHOWCREATEDATABASESCHEMAIFNOTEXISTSDBName

示例

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

MySQL 兼容性

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

另请参阅