SHOW DATABASES

Description

Lists the databases that match an optionally supplied string pattern. If no pattern is supplied then the command lists all the databases in the system. Please note that the usage of SCHEMAS and DATABASES are interchangable and mean the same thing.

Syntax

SHOW {DATABASES|SCHEMAS} [LIKE string_pattern]

Parameters

LIKE string_pattern
Specifies a string pattern that is used to match the databases in the system. In the specified string pattern '*' matches any number of characters.

Examples

-- 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|
  +------------+