From ad7b707658dbc313bcec84f13f630dbda28c295e Mon Sep 17 00:00:00 2001 From: slvrtrn Date: Mon, 18 Sep 2023 22:30:27 +0200 Subject: [PATCH] Update information_schema.tables sql and docs --- .../system-tables/information_schema.md | 4 +- .../System/InformationSchema/tables.sql | 52 +++++++++---------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/docs/en/operations/system-tables/information_schema.md b/docs/en/operations/system-tables/information_schema.md index a532300d336..b990a312019 100644 --- a/docs/en/operations/system-tables/information_schema.md +++ b/docs/en/operations/system-tables/information_schema.md @@ -153,12 +153,14 @@ Columns: - `table_catalog` ([String](../../sql-reference/data-types/string.md)) — The name of the database in which the table is located. - `table_schema` ([String](../../sql-reference/data-types/string.md)) — The name of the database in which the table is located. - `table_name` ([String](../../sql-reference/data-types/string.md)) — Table name. -- `table_type` ([Enum8](../../sql-reference/data-types/enum.md)) — Table type. Possible values: +- `table_type` ([String](../../sql-reference/data-types/string.md)) — Table type. Possible values: - `BASE TABLE` - `VIEW` - `FOREIGN TABLE` - `LOCAL TEMPORARY` - `SYSTEM VIEW` +- `table_comment` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — The comment used when creating the table. +- `table_collation` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — The table default collation. Always `utf8mb4`. **Example** diff --git a/src/Storages/System/InformationSchema/tables.sql b/src/Storages/System/InformationSchema/tables.sql index 90b70332dbf..34dbd108342 100644 --- a/src/Storages/System/InformationSchema/tables.sql +++ b/src/Storages/System/InformationSchema/tables.sql @@ -1,28 +1,28 @@ ATTACH VIEW tables - ( - `table_catalog` String, - `table_schema` String, - `table_name` String, - `table_type` String, - `table_comment` String, - `table_collation` String, - `TABLE_CATALOG` String ALIAS table_catalog, - `TABLE_SCHEMA` String ALIAS table_schema, - `TABLE_NAME` String ALIAS table_name, - `TABLE_TYPE` String ALIAS table_type, - `TABLE_COMMENT` String ALIAS table_comment, - `TABLE_COLLATION` String ALIAS table_collation - ) AS -SELECT database AS `table_catalog`, - database AS `table_schema`, - name AS `table_name`, - comment AS `table_comment`, - multiIf( - is_temporary, 'LOCAL TEMPORARY', - engine LIKE '%View', 'VIEW', - engine LIKE 'System%', 'SYSTEM VIEW', - has_own_data = 0, 'FOREIGN TABLE', - 'BASE TABLE' - ) AS `table_type`, - 'utf8mb4' AS `table_collation` +( + `table_catalog` String, + `table_schema` String, + `table_name` String, + `table_type` String, + `table_comment` Nullable(String), + `table_collation` Nullable(String), + `TABLE_CATALOG` String ALIAS table_catalog, + `TABLE_SCHEMA` String ALIAS table_schema, + `TABLE_NAME` String ALIAS table_name, + `TABLE_TYPE` String ALIAS table_type, + `TABLE_COMMENT` Nullable(String) ALIAS table_comment, + `TABLE_COLLATION` Nullable(String) ALIAS table_collation +) AS +SELECT + database AS table_catalog, + database AS table_schema, + name AS table_name, + comment AS table_comment, + multiIf(is_temporary, 'LOCAL TEMPORARY', + engine LIKE '%View', 'VIEW', + engine LIKE 'System%', 'SYSTEM VIEW', + has_own_data = 0, 'FOREIGN TABLE', + 'BASE TABLE' + ) AS table_type, + 'utf8mb4' AS table_collation FROM system.tables