SHOW DATABASES

描述

列出与可选提供的正则表达式模式匹配的数据库。如果没有提供模式,则该命令会列出系统中的所有数据库。请注意,SCHEMASDATABASES 的用法是可以互换的,并且含义相同。

语法

SHOW { DATABASES | SCHEMAS } [ LIKE regex_pattern ]

参数

示例

-- Create database. Assumes a database named `default` already exists in
-- the system. 
CREATE DATABASE payroll_db;
CREATE DATABASE payments_db;

-- Lists all the databases. 
SHOW DATABASES;
+------------+
|databaseName|
+------------+
|     default|
| payments_db|
|  payroll_db|
+------------+
  
-- Lists databases with name starting with string pattern `pay`
SHOW DATABASES LIKE 'pay*';
+------------+
|databaseName|
+------------+
| payments_db|
|  payroll_db|
+------------+
  
-- Lists all databases. Keywords SCHEMAS and DATABASES are interchangeable. 
SHOW SCHEMAS;
+------------+
|databaseName|
+------------+
|     default|
| payments_db|
|  payroll_db|
+------------+