Skip to main content
The SHOW TABLES lists the schema, table name, table type, owner, and estimated row count for the tables or in a schema or database.
While a table or view is being , SHOW TABLES will list the object with a (dropped) suffix.

Synopsis

show_tables syntax diagram

Required privileges

The CONNECT on the database of the concerned table is required to list it with SHOW TABLES.

Parameters

ParameterDescription
database\_nameThe name of the database for which to show tables.
schema\_nameThe name of the schema for which to show tables.
When a database_name and schema_name are omitted, the tables of the in the 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 .

Performance

To optimize the performance of the SHOW TABLES statement, you can do the following:
  • Disable table row-count estimation by setting the sql.show_tables.estimated_row_count.enabled to false before executing a SHOW TABLES statement.
  • Avoid running SHOW TABLES on databases with a large number of tables (e.g., more than 10,000 tables).

Examples

Setup

The following examples use MovR, a fictional vehicle-sharing application, to demonstrate CockroachDB SQL statements. For more information about the MovR example application and dataset, see . To follow along, run with the and flags. This command opens an interactive SQL shell to a temporary, multi-node in-memory cluster with the movr database preloaded and set as the .

Show tables in the current database

SHOW TABLES uses the public set by default in search_path:
Alternatively, within the built-in SQL shell, you can use the \dt :

Show tables in a different schema

You can show the tables in schemas other than the current schema. You can also show the schema by table:
Because movr is the current database, these statements return the same output:

Show tables in a different database

You can also show tables from a different database.
Because public is the current schema, these statements return the same output:

Show user-defined tables with comments

You can use to add comments on a table.
To view a table’s comments:
You can also view comments on a table with :
For more information, see .

Show virtual tables with comments

The virtual tables in the pg_catalog, information_schema, and crdb_internal schemas contain useful comments, often with links to further documentation. To view virtual tables with comments and documentation links, use SHOW TABLES FROM <virtual schema> WITH COMMENT:

Show locality of tables

For tables, you can display the locality of each table using the SHOW TABLES command.
  1. on movr to us-east:
    All tables will be in the primary region by default.
  2. Configure the users table to be :
Locality information for tables is also available in the locality column within the table.

See also