Skip to main content
The information_schema contains information about your database’s tables, columns, indexes, and views. This information can be used for introspection and reflection.

Data exposed by information_schema

To perform introspection on objects, you can either read from the related information_schema table or use one of CockroachDB’s SHOW statements. information_schema tables are read-only.

Tables in information_schema

The virtual schema information_schema contains virtual tables, also called “system views,” representing the database’s objects, each of which is detailed below. These differ from regular in that they do not show data created from the content of other tables. Instead, CockroachDB generates the data for virtual tables when they are accessed.
A query can specify a table name without a database name (e.g., SELECT * FROM information_schema.sequences). See for more information.
The virtual tables in information_schema contain useful comments with links to further documentation. To view these comments, use SHOW TABLES FROM information_schema WITH COMMENT:

administrable_role_authorizations

administrable_role_authorizations identifies all roles that the current user has the admin option for.

applicable_roles

applicable_roles identifies all roles whose privileges the current user can use. This implies there is a chain of role grants from the current user to the role in question. The current user itself is also an applicable role, but is not listed.

character_sets

character_sets identifies the character sets available in the current database.

check_constraints

check_constraints contains information about the constraints applied to columns in a database.

collations

collations identifies the collations available in the current database.

collation_character_set_applicability

collation_character_set_applicability identifies which character set the available collations are applicable to.

columns

columns contains information about the columns in each table.

column_privileges

column_privileges identifies all privileges granted on columns to or by a currently enabled role. There is one row for each combination of grantor, grantee, and column (defined by table_catalog, table_schema, table_name, and column_name).

column_udt_usage

column_udt_usage identifies all columns that use data types owned by a currently-enabled role.

constraint_column_usage

constraint_column_usage identifies all columns in a database that are used by some .

enabled_roles

The enabled_roles view identifies enabled roles for the current user. This includes both direct and indirect roles.

key_column_usage

key_column_usage identifies columns with , , or constraints.

referential_constraints

referential_constraints identifies all referential () constraints.

role_table_grants

role_table_grants identifies which have been granted on tables or views where the grantor or grantee is a currently enabled role. This table is identical to table_privileges.

schema_privileges

schema_privileges identifies which have been granted to each user at the database level.

schemata

schemata identifies the database’s schemas.

sequences

sequences identifies defined in a database.

session_variables

session_variables contains information about the for your session. session_variables contains a variable column and a value column. The value column corresponds to the output of the statement. For a list of the session variables, see . For a list of the session variables that have been updated from default values, see .

statistics

statistics identifies table .

table_constraints

table_constraints identifies applied to tables.

table_privileges

table_privileges identifies which have been granted to each user at the table level.

tables

tables identifies tables and views in the database.

type_privileges

type_privileges contains information about privileges on the user-defined types in the current database.

user_privileges

user_privileges identifies global .

views

views identifies in the database.

Empty tables

For compatibility with third-party PostgreSQL and MySQL tooling, information_schema includes the following empty tables:
  • attributes
  • check_constraint_routine_usage
  • column_column_usage
  • column_domain_usage
  • column_options
  • column_statistics
  • columns_extensions
  • constraint_table_usage
  • data_type_privileges
  • domain_constraints
  • domain_udt_usage
  • domains
  • element_types
  • engines
  • events
  • files
  • foreign_data_wrapper_options
  • foreign_data_wrappers
  • foreign_server_options
  • foreign_servers
  • foreign_table_options
  • foreign_tables
  • information_schema_catalog_name
  • keywords
  • optimizer_trace
  • parameters
  • partitions
  • plugins
  • processlist
  • profiling
  • resource_groups
  • role_column_grants
  • role_routine_grants
  • role_udt_grants
  • role_usage_grants
  • routines
  • routine_privileges
  • schemata_extensions
  • sql_features
  • sql_implementation_info
  • sql_parts
  • sql_sizing
  • st_geometry_columns
  • st_spatial_reference_systems
  • st_units_of_measure
  • table_constraints_extensions
  • tables_extensions
  • tablespaces
  • tablespaces_extensions
  • transforms
  • triggered_update_columns
  • triggers
  • udt_privileges
  • usage_privileges
  • user_attributes
  • user_defined_types
  • user_mapping_options
  • user_mappings
  • view_column_usage
  • view_routine_usage
  • view_table_usage

Querying information_schema tables

You can run on the tables in information_schema.
The information_schema views typically represent objects that the current user has privilege to access. To ensure you can view all the objects in a database, access it as a user with .
Unless specified otherwise, queries to information_schema assume the .
For example, to retrieve all columns from the table_constraints table:
And to retrieve specific columns from the table_constraints table:

See also