SHOW DATABASES
Function
Lists all schemas or queries schemas by condition.
Precautions
- The B-compatible SHOW DATABASES command is used to query databases, and the openGauss SHOW DATABASES command is used to query schemas.
- Schemas are displayed by name.
Syntax
SHOW {DATABASES | SCHEMAS} [LIKE 'pattern' | WHERE expr]
Parameter Description
- {DATABASES | SCHEMAS} - The two are equivalent.
- [LIKE 'pattern' | WHERE expr] - The **pattern** supports the LIKE syntax, which can be the full name or part of schema\_name for fuzzy query. The expr supports any expression. The common usage is **show database where database = 'name'**.
Examples
--View all schemas in the current database.
openGauss=# create schema a1;
CREATE SCHEMA
openGauss=# show databases;
      Database
--------------------
 a1
 blockchain
 cstore
 db4ai
 dbe_perf
 dbe_pldebugger
 dbe_pldeveloper
 information_schema
 pg_catalog
 pg_toast
 pkg_service
 public
 snapshot
 sqladvisor
(14 rows)
--Query schemas by condition.
openGauss=# create schema abb1;
CREATE SCHEMA
openGauss=# create schema abb2;
CREATE SCHEMA
openGauss=# create schema abb3;
CREATE SCHEMA
openGauss=# show databases like '%bb%';
 Database
----------
 abb1
 abb2
 abb3
(3 rows)
openGauss=# show databases like 'a%';
 Database
----------
 a1
 abb1
 abb2
 abb3
(4 rows)
openGauss=# show schemas where database = 'a1';
 Database
----------
 a1
(1 row)
Feedback