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.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 .
crdb_cluster_active_session_history
Thecrdb_cluster_active_session_history view tracks cluster-wide in-memory samples.
For more information, refer to the .
crdb_jobs
Thecrdb_jobs view contains metadata for each on the cluster. This view is a stable interface intended for programmatic monitoring of jobs. To monitor jobs in the DB Console, use the .
The view returns only jobs that the current user owns, including through membership in the owning role, or can view with the VIEWJOB . Jobs that have reached the succeeded, failed, or canceled state are removed from the view after the retention period set by the cluster setting.
crdb_jobs reads only job metadata and is the least expensive way to query jobs programmatically. To include each job’s current progress, use crdb_jobs_with_progress.
To retrieve the message history or progress history of a specific job, use the information_schema.crdb_job_messages(job_id) and information_schema.crdb_job_progress_history(job_id) . The job_id argument is required. An unknown job_id, or a job that is not visible to the current user, returns zero rows. Fetching a job’s history can cause contention, so use these functions to inspect specific jobs. Do not call them on large numbers of jobs at once.
crdb_jobs_with_progress
Thecrdb_jobs_with_progress view contains the same job metadata as crdb_jobs, along with each job’s current progress and status message. Because it joins additional system tables, it is more expensive to query than crdb_jobs.
The view returns only jobs that the current user owns, including through membership in the owning role, or can view with the VIEWJOB . Jobs that have reached the succeeded, failed, or canceled state are removed from the view after the retention period set by the cluster setting.
crdb_node_active_session_history
Thecrdb_node_active_session_history view tracks in-memory samples from the local node. It has the same columns as crdb_cluster_active_session_history.
For more information, refer to the .
crdb_persisted_active_session_history
Thecrdb_persisted_active_session_history view tracks persisted, cluster-wide samples. It has the same columns as crdb_cluster_active_session_history.
For more information, refer to the .
enabled_roles
Theenabled_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:
attributescheck_constraint_routine_usagecolumn_column_usagecolumn_domain_usagecolumn_optionscolumn_statisticscolumns_extensionsconstraint_table_usagedata_type_privilegesdomain_constraintsdomain_udt_usagedomainselement_typesengineseventsfilesforeign_data_wrapper_optionsforeign_data_wrappersforeign_server_optionsforeign_serversforeign_table_optionsforeign_tablesinformation_schema_catalog_namekeywordsoptimizer_traceparameterspartitionspluginsprocesslistprofilingresource_groupsrole_column_grantsrole_routine_grantsrole_udt_grantsrole_usage_grantsroutinesroutine_privilegesschemata_extensionssql_featuressql_implementation_infosql_partssql_sizingst_geometry_columnsst_spatial_reference_systemsst_units_of_measuretable_constraints_extensionstables_extensionstablespacestablespaces_extensionstransformstriggered_update_columnstriggersudt_privilegesusage_privilegesuser_attributesuser_defined_typesuser_mapping_optionsuser_mappingsview_column_usageview_routine_usageview_table_usage
Querying information_schema tables
You can run on the tables in information_schema.
Unless specified otherwise, queries to
information_schema assume the .table_constraints table:
table_constraints table:

