SHOW TABLES

On this page Carat arrow pointing down
Warning:
CockroachDB v2.1 is no longer supported as of April 30, 2020. For more details, refer to the Release Support Policy.

The SHOW TABLES statement lists the tables or views in a schema or database.

Note:
While a table or view is being dropped, SHOW TABLES will list the object with a (dropped) suffix.

Synopsis

SHOW TABLES FROM name

Required privileges

No privileges are required to list the tables in a schema or database.

Parameters

Parameter Description
name The name of the schema or database for which to show tables. When omitted, the tables of the current schema in the current database are listed.

SHOW TABLES will attempt to find a schema with the specified name first. If that fails, it will try to find a database with that name instead, and list the tables of its public schema. For more details, see Name Resolution.

Examples

These example assumes that the bank database has been set as the current database for the session, either via the SET statement or in the client's connection string.

Show tables in the current database

icon/buttons/copy
> SHOW TABLES;
+---------------+
| table_name    |
+---------------+
| accounts      |
| user_accounts |
+---------------+
(2 rows)

This uses the current schema public set by default in search_path.

Show tables in a different schema

icon/buttons/copy
> SHOW TABLES FROM information_schema;
icon/buttons/copy
> SHOW TABLES FROM bank.information_schema; -- also possible
+-----------------------------------+
|            table_name             |
+-----------------------------------+
| administrable_role_authorizations |
| applicable_roles                  |
| column_privileges                 |
| columns                           |
| constraint_column_usage           |
| enabled_roles                     |
| key_column_usage                  |
| parameters                        |
| referential_constraints           |
| role_table_grants                 |
| routines                          |
| schema_privileges                 |
| schemata                          |
| sequences                         |
| statistics                        |
| table_constraints                 |
| table_privileges                  |
| tables                            |
| user_privileges                   |
| views                             |
+-----------------------------------+
(20 rows)

Show tables in a different database

icon/buttons/copy
> SHOW TABLES FROM startrek.public;
icon/buttons/copy
> SHOW TABLES FROM startrek; -- also possible
+-------------------+
| table_name        |
+-------------------+
| episodes          |
| quotes            |
| quotes_per_season |
+-------------------+
(3 rows)

See also


Yes No
On this page

Yes No