SHOW TABLES

On this page Carat arrow pointing down
Warning:
CockroachDB v2.0 is no longer supported as of October 4, 2019. 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 Changed in v2.0: 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

> SHOW TABLES;
+---------------+
|     Table     |
+---------------+
| accounts      |
| user_accounts |
+---------------+
(2 rows)

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

Show Tables in a Different Schema

> SHOW TABLES FROM information_schema;
> SHOW TABLES FROM bank.information_schema; -- also possible
+-----------------------------------+
|               Table               |
+-----------------------------------+
| administrable_role_authorizations |
| applicable_roles                  |
| column_privileges                 |
| columns                           |
| constraint_column_usage           |
| enabled_roles                     |
| key_column_usage                  |
| referential_constraints           |
| role_table_grants                 |
| schema_privileges                 |
| schemata                          |
| sequences                         |
| statistics                        |
| table_constraints                 |
| table_privileges                  |
| tables                            |
| user_privileges                   |
| views                             |
+-----------------------------------+
(18 rows)

Show Tables in a Different Database

> SHOW TABLES FROM startrek.public;
> SHOW TABLES FROM startrek; -- also possible
+-------------------+
|       Table       |
+-------------------+
| episodes          |
| quotes            |
| quotes_per_season |
+-------------------+
(3 rows)

See Also


Yes No
On this page

Yes No