INFORMATION_SCHEMA
INFORMATION_SCHEMA
(or: information_schema
) is a system database which provides a (somewhat) standardized, DBMS-agnostic view on metadata of database objects. The views in INFORMATION_SCHEMA
are generally inferior to normal system tables but tools can use them to obtain basic information in a cross-DBMS manner. The structure and content of views in INFORMATION_SCHEMA
is supposed to evolves in a backwards-compatible way, i.e. only new functionality is added but existing functionality is not changed or removed. In terms of internal implementation, views in INFORMATION_SCHEMA
usually map to to normal system tables like system.columns, system.databases and system.tables.
INFORMATION_SCHEMA
contains the following views:
Case-insensitive equivalent views, e.g. INFORMATION_SCHEMA.columns
are provided for reasons of compatibility with other databases. The same applies to all the columns in these views - both lowercase (for example, table_name
) and uppercase (TABLE_NAME
) variants are provided.
COLUMNS
Contains columns read from the system.columns system table and columns that are not supported in ClickHouse or do not make sense (always NULL
), but must be by the standard.
Columns:
table_catalog
(String) — The name of the database in which the table is located.table_schema
(String) — The name of the database in which the table is located.table_name
(String) — Table name.column_name
(String) — Column name.ordinal_position
(UInt64) — Ordinal position of a column in a table starting with 1.column_default
(String) — Expression for the default value, or an empty string if it is not defined.is_nullable
(UInt8) — Flag that indicates whether the column type isNullable
.data_type
(String) — Column type.character_maximum_length
(Nullable(UInt64)) — Maximum length in bytes for binary data, character data, or text data and images. In ClickHouse makes sense only forFixedString
data type. Otherwise, theNULL
value is returned.character_octet_length
(Nullable(UInt64)) — Maximum length in bytes for binary data, character data, or text data and images. In ClickHouse makes sense only forFixedString
data type. Otherwise, theNULL
value is returned.numeric_precision
(Nullable(UInt64)) — Accuracy of approximate numeric data, exact numeric data, integer data, or monetary data. In ClickHouse it is bit width for integer types and decimal precision forDecimal
types. Otherwise, theNULL
value is returned.numeric_precision_radix
(Nullable(UInt64)) — The base of the number system is the accuracy of approximate numeric data, exact numeric data, integer data or monetary data. In ClickHouse it's 2 for integer types and 10 forDecimal
types. Otherwise, theNULL
value is returned.numeric_scale
(Nullable(UInt64)) — The scale of approximate numeric data, exact numeric data, integer data, or monetary data. In ClickHouse makes sense only forDecimal
types. Otherwise, theNULL
value is returned.datetime_precision
(Nullable(UInt64)) — Decimal precision ofDateTime64
data type. For other data types, theNULL
value is returned.character_set_catalog
(Nullable(String)) —NULL
, not supported.character_set_schema
(Nullable(String)) —NULL
, not supported.character_set_name
(Nullable(String)) —NULL
, not supported.collation_catalog
(Nullable(String)) —NULL
, not supported.collation_schema
(Nullable(String)) —NULL
, not supported.collation_name
(Nullable(String)) —NULL
, not supported.domain_catalog
(Nullable(String)) —NULL
, not supported.domain_schema
(Nullable(String)) —NULL
, not supported.domain_name
(Nullable(String)) —NULL
, not supported.extra
(Nullable(String)) —STORED GENERATED
forMATERIALIZED
-type columns,VIRTUAL GENERATED
forALIAS
-type columns,DEFAULT_GENERATED
forDEFAULT
-type columns, orNULL
.
Example
Query:
Result:
SCHEMATA
Contains columns read from the system.databases system table and columns that are not supported in ClickHouse or do not make sense (always NULL
), but must be by the standard.
Columns:
catalog_name
(String) — The name of the database.schema_name
(String) — The name of the database.schema_owner
(String) — Schema owner name, always'default'
.default_character_set_catalog
(Nullable(String)) —NULL
, not supported.default_character_set_schema
(Nullable(String)) —NULL
, not supported.default_character_set_name
(Nullable(String)) —NULL
, not supported.sql_path
(Nullable(String)) —NULL
, not supported.
Example
Query:
Result:
TABLES
Contains columns read from the system.tables system table.
Columns:
table_catalog
(String) — The name of the database in which the table is located.table_schema
(String) — The name of the database in which the table is located.table_name
(String) — Table name.table_type
(String) — Table type. Possible values:BASE TABLE
VIEW
FOREIGN TABLE
LOCAL TEMPORARY
SYSTEM VIEW
table_rows
(Nullable(UInt64)) — The total number of rows. NULL if it could not be determined.data_length
(Nullable(UInt64)) — The size of the data on-disk. NULL if it could not be determined.table_collation
(Nullable(String)) — The table default collation. Alwaysutf8mb4_0900_ai_ci
.table_comment
(Nullable(String)) — The comment used when creating the table.
Example
Query:
Result:
VIEWS
Contains columns read from the system.tables system table, when the table engine View is used.
Columns:
table_catalog
(String) — The name of the database in which the table is located.table_schema
(String) — The name of the database in which the table is located.table_name
(String) — Table name.view_definition
(String) —SELECT
query for view.check_option
(String) —NONE
, no checking.is_updatable
(Enum8) —NO
, the view is not updated.is_insertable_into
(Enum8) — Shows whether the created view is materialized. Possible values:NO
— The created view is not materialized.YES
— The created view is materialized.
is_trigger_updatable
(Enum8) —NO
, the trigger is not updated.is_trigger_deletable
(Enum8) —NO
, the trigger is not deleted.is_trigger_insertable_into
(Enum8) —NO
, no data is inserted into the trigger.
Example
Query:
Result:
KEY_COLUMN_USAGE
Contains columns from the system.tables system table which are restricted by constraints.
Columns:
constraint_catalog
(String) — Currently unused. Alwaysdef
.constraint_schema
(String) — The name of the schema (database) to which the constraint belongs.constraint_name
(Nullable(String)) — The name of the constraint.table_catalog
(String) — Currently unused. Alwaysdef
.table_schema
(String) — The name of the schema (database) to which the table belongs.table_name
(String) — The name of the table that has the constraint.column_name
(Nullable(String)) — The name of the column that has the constraint.ordinal_position
(UInt32) — Currently unused. Always1
.position_in_unique_constraint
(Nullable(UInt32)) — Currently unused. AlwaysNULL
.referenced_table_schema
(Nullable(String)) — Currently unused. Always NULL.referenced_table_name
(Nullable(String)) — Currently unused. Always NULL.referenced_column_name
(Nullable(String)) — Currently unused. Always NULL.
Example
Result:
REFERENTIAL_CONSTRAINTS
Contains information about foreign keys. Currently returns an empty result (no rows) which is just enough to provide compatibility with 3rd party tools like Tableau Online.
Columns:
constraint_catalog
(String) — Currently unused.constraint_schema
(String) — Currently unused.constraint_name
(Nullable(String)) — Currently unused.unique_constraint_catalog
(String) — Currently unused.unique_constraint_schema
(String) — Currently unused.unique_constraint_name
(Nullable(String)) — Currently unused.match_option
(String) — Currently unused.update_rule
(String) — Currently unused.delete_rule
(String) — Currently unused.table_name
(String) — Currently unused.referenced_table_name
(String) — Currently unused.
STATISTICS
Provides information about table indexes. Currently returns an empty result (no rows) which is just enough to provide compatibility with 3rd party tools like Tableau Online.
Columns:
table_catalog
(String) — Currently unused.table_schema
(String) — Currently unused.table_name
(String) — Currently unused.non_unique
(Int32) — Currently unused.index_schema
(String) — Currently unused.index_name
(Nullable(String)) — Currently unused.seq_in_index
(UInt32) — Currently unused.column_name
(Nullable(String)) — Currently unused.collation
(Nullable(String)) — Currently unused.cardinality
(Nullable(Int64)) — Currently unused.sub_part
(Nullable(Int64)) — Currently unused.packed
(Nullable(String)) — Currently unused.nullable
(String) — Currently unused.index_type
(String) — Currently unused.comment
(String) — Currently unused.index_comment
(String) — Currently unused.is_visible
(String) — Currently unused.expression
(Nullable(String)) — Currently unused.