HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

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 MogDB 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.
MogDB=# create schema a1;
CREATE SCHEMA

MogDB=# 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.
MogDB=# create schema abb1;
CREATE SCHEMA
MogDB=# create schema abb2;
CREATE SCHEMA
MogDB=# create schema abb3;
CREATE SCHEMA
MogDB=# show databases like '%bb%';
 Database
----------
 abb1
 abb2
 abb3
(3 rows)

MogDB=# show databases like 'a%';
 Database
----------
 a1
 abb1
 abb2
 abb3
(4 rows)

MogDB=# show schemas where database = 'a1';
 Database
----------
 a1
(1 row)
Copyright © 2011-2024 www.enmotech.com All rights reserved.