Project: ClickHouse (App Definition and Development / Database)
File: information_schema.md

slug: /en/operations/system-tables/information_schema `INFORMATIONSCHEMA` (or: `informationschema`) is a system database which provides a (somewhat) standardized, on metadata of database objects. The views in `INFORMATIONSCHEMA` 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 `INFORMATIONSCHEMA` 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 , and . ``` sql SHOW TABLES FROM INFORMATION_SCHEMA; -- or: SHOW TABLES FROM information_schema; ``` ``` text name COLUMNS KEYCOLUMNUSAGE REFERENTIAL_CONSTRAINTS SCHEMATA | STATISTICS | TABLES VIEWS columns keycolumnusage referential_constraints schemata | statistics | tables views ``` `INFORMATION_SCHEMA` contains the following views: Case-insensitive equivalent views, e.g. `INFORMATIONSCHEMA.columns` are provided for reasons of compatibility with other databases. The same applies to all the columns in these views - both lowercase (for example, `tablename`) and uppercase (`TABLE_NAME`) variants are provided. Contains columns read from the 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` () The name of the database in which the table is located. `table_schema` () The name of the database in which the table is located. `table_name` () Table name. `column_name` () Column name. `ordinal_position` () Ordinal position of a column in a table starting with 1. `column_default` () Expression for the default value, or an empty string if it is not defined. `is_nullable` () Flag that indicates whether the column type is `Nullable`. `data_type` () Column type. `charactermaximumlength` (()) Maximum length in bytes for binary data, character data, or text data and images. In ClickHouse makes sense only for `FixedString` data type. Otherwise, the `NULL` value is returned. `characteroctetlength` (()) Maximum length in bytes for binary data, character data, or text data and images. In ClickHouse makes sense only for `FixedString` data type. Otherwise, the `NULL` value is returned. `numeric_precision` (()) 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 for `Decimal` types. Otherwise, the `NULL` value is returned. `numericprecisionradix` (()) 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 for `Decimal` types. Otherwise, the `NULL` value is returned. `numeric_scale` (()) The scale of approximate numeric data, exact numeric data, integer data, or monetary data. In ClickHouse makes sense only for `Decimal` types. Otherwise, the `NULL` value is returned. `datetime_precision` (()) Decimal precision of `DateTime64` data type. For other data types, the `NULL` value is returned. `charactersetcatalog` (()) `NULL`, not

`charactersetschema` (()) `NULL`, not supported. `charactersetname` (()) `NULL`, not supported. `collation_catalog` (()) `NULL`, not supported. `collation_schema` (()) `NULL`, not supported. `collation_name` (()) `NULL`, not supported. `domain_catalog` (()) `NULL`, not supported. `domain_schema` (()) `NULL`, not supported. `domain_name` (()) `NULL`, not supported. `extra` (()) `STORED GENERATED` for `MATERIALIZED`-type columns, `VIRTUAL GENERATED` for `ALIAS`-type columns, `DEFAULT_GENERATED` for `DEFAULT`-type columns, or `NULL`. Example Query: ``` sql SELECT table_catalog, table_schema, table_name, column_name, ordinal_position, column_default, is_nullable, data_type, charactermaximumlength, characteroctetlength, numeric_precision, numericprecisionradix, numeric_scale, datetime_precision, charactersetcatalog, charactersetschema, charactersetname, collation_catalog, collation_schema, collation_name, domain_catalog, domain_schema, domain_name, column_comment, column_type FROM INFORMATION_SCHEMA.COLUMNS WHERE (tableschema = currentDatabase() OR tableschema = '') AND table_name NOT LIKE '%inner%' LIMIT 1 FORMAT Vertical; ``` Result: ``` text Row 1: table_catalog: default table_schema: default tablename: describeexample column_name: id ordinal_position: 1 column_default: is_nullable: 0 data_type: UInt64 charactermaximumlength: characteroctetlength: numeric_precision: 64 numericprecisionradix: 2 numeric_scale: 0 datetime_precision: charactersetcatalog: charactersetschema: charactersetname: collation_catalog: collation_schema: collation_name: domain_catalog: domain_schema: domain_name: ``` Contains columns read from the 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` () The name of the database. `schema_name` () The name of the database. `schema_owner` () Schema owner name, always `'default'`. `defaultcharacterset_catalog` (()) `NULL`, not supported. `defaultcharacterset_schema` (()) `NULL`, not supported. `defaultcharacterset_name` (()) `NULL`, not supported. `sql_path` (()) `NULL`, not supported. Example Query: ``` sql SELECT catalog_name, schema_name, schema_owner, defaultcharacterset_catalog, defaultcharacterset_schema, defaultcharacterset_name, sql_path FROM information_schema.schemata WHERE schemaname ilike 'informationschema' LIMIT 1 FORMAT Vertical; ``` Result: ``` text Row 1: catalogname: INFORMATIONSCHEMA schemaname: INFORMATIONSCHEMA schema_owner: default defaultcharacterset_catalog: defaultcharacterset_schema: defaultcharacterset_name: sql_path: ``` Contains columns read from the system table. Columns: `table_catalog` () The name of the database in which the table is located. `table_schema` () The name of the database in which the table is located. `table_name` () Table name. `table_type` () Table type. Possible values: `BASE TABLE` `VIEW` `FOREIGN TABLE` `LOCAL TEMPORARY` `SYSTEM VIEW` `table_rows` (()) The total number of rows. NULL if it could not be determined. `data_length` (()) The size of the data on-disk. NULL if it could not be determined. `tablecollation` (()) The table default collation. Always `utf8mb40900aici`. `table_comment` (()) The comment used when creating the table. Example Query: ``` sql SELECT table_catalog, table_schema, table_name, table_type, table_collation, table_comment FROM INFORMATION_SCHEMA.TABLES WHERE (tableschema = currentDatabase() OR tableschema = '') AND table_name NOT LIKE '%inner%' LIMIT 1 FORMAT Vertical; ``` Result: ``` text Row 1: table_catalog: default table_schema: default tablename: describeexample table_type: BASE TABLE tablecollation: utf8mb40900aici table_comment: ``` Contains columns read from the system table, when the table engine is used. Columns: `table_catalog` () The name of the database in which the table is located. `table_schema` () The name of the database in which the table is located. `table_name` () Table name. `view_definition` () `SELECT` query for view. `check_option` () `NONE`, no checking. `is_updatable` () `NO`, the view is not

`isinsertableinto` () Shows whether the created view is . Possible values: `NO` The created view is not materialized. `YES` The created view is materialized. `istriggerupdatable` () `NO`, the trigger is not updated. `istriggerdeletable` () `NO`, the trigger is not deleted. `istriggerinsertable_into` () `NO`, no data is inserted into the trigger. Example Query: ``` sql CREATE VIEW v (n Nullable(Int32), f Float64) AS SELECT n, f FROM t; CREATE MATERIALIZED VIEW mv ENGINE = Null AS SELECT * FROM system.one; SELECT table_catalog, table_schema, table_name, view_definition, check_option, is_updatable, isinsertableinto, istriggerupdatable, istriggerdeletable, istriggerinsertable_into FROM information_schema.views WHERE table_schema = currentDatabase() LIMIT 1 FORMAT Vertical; ``` Result: ``` text Row 1: table_catalog: default table_schema: default table_name: mv view_definition: SELECT * FROM system.one check_option: NONE is_updatable: NO isinsertableinto: YES istriggerupdatable: NO istriggerdeletable: NO istriggerinsertable_into: NO ``` Contains columns from the system table which are restricted by constraints. Columns: `constraint_catalog` () Currently unused. Always `def`. `constraint_schema` () The name of the schema (database) to which the constraint belongs. `constraint_name` (()) The name of the constraint. `table_catalog` () Currently unused. Always `def`. `table_schema` () The name of the schema (database) to which the table belongs. `table_name` () The name of the table that has the constraint. `column_name` (()) The name of the column that has the constraint. `ordinal_position` () Currently unused. Always `1`. `positioninunique_constraint` (()) Currently unused. Always `NULL`. `referencedtableschema` (()) Currently unused. Always NULL. `referencedtablename` (()) Currently unused. Always NULL. `referencedcolumnname` (()) Currently unused. Always NULL. Example ```sql CREATE TABLE test (i UInt32, s String) ENGINE MergeTree ORDER BY i; SELECT constraint_catalog, constraint_schema, constraint_name, table_catalog, table_schema, table_name, column_name, ordinal_position, positioninunique_constraint, referencedtableschema, referencedtablename, referencedcolumnname FROM informationschema.keycolumn_usage WHERE table_name = 'test' FORMAT Vertical; ``` Result: ``` Row 1: constraint_catalog: def constraint_schema: default constraint_name: PRIMARY table_catalog: def table_schema: default table_name: test column_name: i ordinal_position: 1 positioninunique_constraint: referencedtableschema: referencedtablename: referencedcolumnname: ``` 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` () Currently unused. `constraint_schema` () Currently unused. `constraint_name` (()) Currently unused. `uniqueconstraintcatalog` () Currently unused. `uniqueconstraintschema` () Currently unused. `uniqueconstraintname` (()) Currently unused. `match_option` () Currently unused. `update_rule` () Currently unused. `delete_rule` () Currently unused. `table_name` () Currently unused. `referencedtablename` () Currently unused. 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` () Currently unused. `table_schema` () Currently unused. `table_name` () Currently unused. `non_unique` () Currently unused. `index_schema` () Currently unused. `index_name` (()) Currently unused. `seqinindex` () Currently unused. `column_name` (()) Currently unused. `collation` (()) Currently unused. `cardinality` (()) Currently unused. `sub_part` (()) Currently unused. `packed` (()) Currently unused. `nullable` () Currently unused. `index_type` () Currently unused. `comment` () Currently unused. `index_comment` () Currently unused. `is_visible` () Currently unused. `expression` (()) Currently unused.