SHOW DATABASES

SHOW DATABASES 语句用于显示当前用户有权访问的数据库列表。当前用户无权访问的数据库将从列表中隐藏。information_schema 数据库始终出现在列表的最前面。

SHOW SCHEMASSHOW DATABASES 语句的别名。

语法图

ShowDatabasesStmt:

ShowDatabasesStmt

SHOW DATABASES - 图1

ShowLikeOrWhere

SHOW DATABASES - 图2

  1. ShowDatabasesStmt ::=
  2. "SHOW" "DATABASES" ShowLikeOrWhere?
  3. ShowLikeOrWhere ::=
  4. "LIKE" SimpleExpr
  5. | "WHERE" Expression

示例

  1. SHOW DATABASES;
  1. +--------------------+
  2. | Database |
  3. +--------------------+
  4. | INFORMATION_SCHEMA |
  5. | PERFORMANCE_SCHEMA |
  6. | mysql |
  7. | test |
  8. +--------------------+
  9. 4 rows in set (0.00 sec)
  1. CREATE DATABASE mynewdb;
  1. Query OK, 0 rows affected (0.10 sec)
  1. SHOW DATABASES;
  1. +--------------------+
  2. | Database |
  3. +--------------------+
  4. | INFORMATION_SCHEMA |
  5. | PERFORMANCE_SCHEMA |
  6. | mynewdb |
  7. | mysql |
  8. | test |
  9. +--------------------+
  10. 5 rows in set (0.00 sec)

MySQL 兼容性

SHOW DATABASES 语句与 MySQL 完全兼容。如发现任何兼容性差异,请尝试 TiDB 支持资源

另请参阅