Replace information_schema view columns aliases with uppercase

This commit is contained in:
slvrtrn 2023-09-19 23:42:40 +02:00
parent e4e9727572
commit 636fc506aa
9 changed files with 430 additions and 150 deletions

View File

@ -38,7 +38,7 @@ SHOW TABLES FROM information_schema;
- [KEY_COLUMN_USAGE](#key_column_usage) - [KEY_COLUMN_USAGE](#key_column_usage)
- [REFERENTIAL_CONSTRAINTS](#referential_constraints) - [REFERENTIAL_CONSTRAINTS](#referential_constraints)
Case-insensitive equivalent views, e.g. `INFORMATION_SCHEMA.columns` are provided for reasons of compatibility with other databases. 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 {#columns} ## COLUMNS {#columns}
@ -75,7 +75,36 @@ Columns:
Query: Query:
``` sql ``` sql
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE (table_schema=currentDatabase() OR table_schema='') AND table_name NOT LIKE '%inner%' LIMIT 1 FORMAT Vertical; SELECT table_catalog,
table_schema,
table_name,
column_name,
ordinal_position,
column_default,
is_nullable,
data_type,
character_maximum_length,
character_octet_length,
numeric_precision,
numeric_precision_radix,
numeric_scale,
datetime_precision,
character_set_catalog,
character_set_schema,
character_set_name,
collation_catalog,
collation_schema,
collation_name,
domain_catalog,
domain_schema,
domain_name,
column_comment,
column_type
FROM INFORMATION_SCHEMA.COLUMNS
WHERE (table_schema = currentDatabase() OR table_schema = '')
AND table_name NOT LIKE '%inner%'
LIMIT 1
FORMAT Vertical;
``` ```
Result: Result:
@ -127,7 +156,17 @@ Columns:
Query: Query:
``` sql ``` sql
SELECT * FROM information_schema.schemata WHERE schema_name ILIKE 'information_schema' LIMIT 1 FORMAT Vertical; SELECT catalog_name,
schema_name,
schema_owner,
default_character_set_catalog,
default_character_set_schema,
default_character_set_name,
sql_path
FROM information_schema.schemata
WHERE schema_name ilike 'information_schema'
LIMIT 1
FORMAT Vertical;
``` ```
Result: Result:
@ -167,7 +206,17 @@ Columns:
Query: Query:
``` sql ``` sql
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (table_schema = currentDatabase() OR table_schema = '') AND table_name NOT LIKE '%inner%' LIMIT 1 FORMAT Vertical; SELECT table_catalog,
table_schema,
table_name,
table_type,
table_collation,
table_comment
FROM INFORMATION_SCHEMA.TABLES
WHERE (table_schema = currentDatabase() OR table_schema = '')
AND table_name NOT LIKE '%inner%'
LIMIT 1
FORMAT Vertical;
``` ```
Result: Result:
@ -175,10 +224,12 @@ Result:
``` text ``` text
Row 1: Row 1:
────── ──────
table_catalog: default table_catalog: default
table_schema: default table_schema: default
table_name: describe_example table_name: describe_example
table_type: BASE TABLE table_type: BASE TABLE
table_collation: utf8mb4_0900_ai_ci
table_comment:
``` ```
## VIEWS {#views} ## VIEWS {#views}
@ -207,7 +258,20 @@ Query:
``` sql ``` sql
CREATE VIEW v (n Nullable(Int32), f Float64) AS SELECT n, f FROM t; 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; CREATE MATERIALIZED VIEW mv ENGINE = Null AS SELECT * FROM system.one;
SELECT * FROM information_schema.views WHERE table_schema = currentDatabase() LIMIT 1 FORMAT Vertical; SELECT table_catalog,
table_schema,
table_name,
view_definition,
check_option,
is_updatable,
is_insertable_into,
is_trigger_updatable,
is_trigger_deletable,
is_trigger_insertable_into
FROM information_schema.views
WHERE table_schema = currentDatabase()
LIMIT 1
FORMAT Vertical;
``` ```
Result: Result:
@ -240,7 +304,7 @@ Columns:
- `table_schema` ([String](../../sql-reference/data-types/string.md)) — The name of the schema (database) to which the table belongs. - `table_schema` ([String](../../sql-reference/data-types/string.md)) — The name of the schema (database) to which the table belongs.
- `table_name` ([String](../../sql-reference/data-types/string.md)) — The name of the table that has the constraint. - `table_name` ([String](../../sql-reference/data-types/string.md)) — The name of the table that has the constraint.
- `column_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — The name of the column that has the constraint. - `column_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — The name of the column that has the constraint.
- `ordinal_position` ([UInt32](../../sql-reference/data-types/int-uint.md)) — The column's position within the constraint, not the column's position within the table. Column positions are numbered beginning with 1. - `ordinal_position` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Currently unused. Always `1`.
- `position_in_unique_constraint` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt32](../../sql-reference/data-types/int-uint.md))) — Currently unused. Always `NULL`. - `position_in_unique_constraint` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt32](../../sql-reference/data-types/int-uint.md))) — Currently unused. Always `NULL`.
- `referenced_table_schema` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — Currently unused. Always NULL. - `referenced_table_schema` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — Currently unused. Always NULL.
- `referenced_table_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — Currently unused. Always NULL. - `referenced_table_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — Currently unused. Always NULL.
@ -250,7 +314,21 @@ Columns:
```sql ```sql
CREATE TABLE test (i UInt32, s String) ENGINE MergeTree ORDER BY i; CREATE TABLE test (i UInt32, s String) ENGINE MergeTree ORDER BY i;
SELECT * FROM information_schema.key_column_usage WHERE table_name = 'test' FORMAT Vertical; SELECT constraint_catalog,
constraint_schema,
constraint_name,
table_catalog,
table_schema,
table_name,
column_name,
ordinal_position,
position_in_unique_constraint,
referenced_table_schema,
referenced_table_name,
referenced_column_name
FROM information_schema.key_column_usage
WHERE table_name = 'test'
FORMAT Vertical;
``` ```
Result: Result:
@ -258,14 +336,18 @@ Result:
``` ```
Row 1: Row 1:
────── ──────
referenced_table_schema: ᴺᵁᴸᴸ constraint_catalog: def
referenced_table_name: ᴺᵁᴸᴸ constraint_schema: default
referenced_column_name: ᴺᵁᴸᴸ constraint_name: PRIMARY
table_schema: default table_catalog: def
table_name: test table_schema: default
column_name: i table_name: test
ordinal_position: 1 column_name: i
constraint_name: PRIMARY ordinal_position: 1
position_in_unique_constraint: ᴺᵁᴸᴸ
referenced_table_schema: ᴺᵁᴸᴸ
referenced_table_name: ᴺᵁᴸᴸ
referenced_column_name: ᴺᵁᴸᴸ
``` ```
## REFERENTIAL_CONSTRAINTS (#referential_constraints) ## REFERENTIAL_CONSTRAINTS (#referential_constraints)

View File

@ -3,8 +3,6 @@ ATTACH VIEW columns
`table_catalog` String, `table_catalog` String,
`table_schema` String, `table_schema` String,
`table_name` String, `table_name` String,
`TABLE_SCHEMA` String,
`TABLE_NAME` String,
`column_name` String, `column_name` String,
`ordinal_position` UInt64, `ordinal_position` UInt64,
`column_default` String, `column_default` String,
@ -27,36 +25,36 @@ ATTACH VIEW columns
`domain_name` Nullable(String), `domain_name` Nullable(String),
`column_comment` String, `column_comment` String,
`column_type` String, `column_type` String,
`TABLE_CATALOG` String ALIAS table_catalog, `TABLE_CATALOG` String,
`COLUMN_NAME` String ALIAS column_name, `TABLE_SCHEMA` String,
`ORDINAL_POSITION` UInt64 ALIAS ordinal_position, `TABLE_NAME` String,
`COLUMN_DEFAULT` String ALIAS column_default, `COLUMN_NAME` String,
`IS_NULLABLE` String ALIAS is_nullable, `ORDINAL_POSITION` UInt64,
`DATA_TYPE` String ALIAS data_type, `COLUMN_DEFAULT` String,
`CHARACTER_MAXIMUM_LENGTH` Nullable(UInt64) ALIAS character_maximum_length, `IS_NULLABLE` String,
`CHARACTER_OCTET_LENGTH` Nullable(UInt64) ALIAS character_octet_length, `DATA_TYPE` String,
`NUMERIC_PRECISION` Nullable(UInt64) ALIAS numeric_precision, `CHARACTER_MAXIMUM_LENGTH` Nullable(UInt64),
`NUMERIC_PRECISION_RADIX` Nullable(UInt64) ALIAS numeric_precision_radix, `CHARACTER_OCTET_LENGTH` Nullable(UInt64),
`NUMERIC_SCALE` Nullable(UInt64) ALIAS numeric_scale, `NUMERIC_PRECISION` Nullable(UInt64),
`DATETIME_PRECISION` Nullable(UInt64) ALIAS datetime_precision, `NUMERIC_PRECISION_RADIX` Nullable(UInt64),
`CHARACTER_SET_CATALOG` Nullable(String) ALIAS character_set_catalog, `NUMERIC_SCALE` Nullable(UInt64),
`CHARACTER_SET_SCHEMA` Nullable(String) ALIAS character_set_schema, `DATETIME_PRECISION` Nullable(UInt64),
`CHARACTER_SET_NAME` Nullable(String) ALIAS character_set_name, `CHARACTER_SET_CATALOG` Nullable(String),
`COLLATION_CATALOG` Nullable(String) ALIAS collation_catalog, `CHARACTER_SET_SCHEMA` Nullable(String),
`COLLATION_SCHEMA` Nullable(String) ALIAS collation_schema, `CHARACTER_SET_NAME` Nullable(String),
`COLLATION_NAME` Nullable(String) ALIAS collation_name, `COLLATION_CATALOG` Nullable(String),
`DOMAIN_CATALOG` Nullable(String) ALIAS domain_catalog, `COLLATION_SCHEMA` Nullable(String),
`DOMAIN_SCHEMA` Nullable(String) ALIAS domain_schema, `COLLATION_NAME` Nullable(String),
`DOMAIN_NAME` Nullable(String) ALIAS domain_name, `DOMAIN_CATALOG` Nullable(String),
`COLUMN_COMMENT` String ALIAS column_comment, `DOMAIN_SCHEMA` Nullable(String),
`COLUMN_TYPE` String ALIAS column_type `DOMAIN_NAME` Nullable(String),
`COLUMN_COMMENT` String,
`COLUMN_TYPE` String
) AS ) AS
SELECT SELECT
database AS table_catalog, database AS table_catalog,
database AS table_schema, database AS table_schema,
database AS TABLE_SCHEMA,
table AS table_name, table AS table_name,
table AS TABLE_NAME,
name AS column_name, name AS column_name,
position AS ordinal_position, position AS ordinal_position,
default_expression AS column_default, default_expression AS column_default,
@ -78,5 +76,30 @@ SELECT
NULL AS domain_schema, NULL AS domain_schema,
NULL AS domain_name, NULL AS domain_name,
comment AS column_comment, comment AS column_comment,
type AS column_type type AS column_type,
table_catalog AS TABLE_CATALOG,
table_schema AS TABLE_SCHEMA,
table_name AS TABLE_NAME,
column_name AS COLUMN_NAME,
ordinal_position AS ORDINAL_POSITION,
column_default AS COLUMN_DEFAULT,
is_nullable AS IS_NULLABLE,
data_type AS DATA_TYPE,
character_maximum_length AS CHARACTER_MAXIMUM_LENGTH,
character_octet_length AS CHARACTER_OCTET_LENGTH,
numeric_precision AS NUMERIC_PRECISION,
numeric_precision_radix AS NUMERIC_PRECISION_RADIX,
numeric_scale AS NUMERIC_SCALE,
datetime_precision AS DATETIME_PRECISION,
character_set_catalog AS CHARACTER_SET_CATALOG,
character_set_schema AS CHARACTER_SET_SCHEMA,
character_set_name AS CHARACTER_SET_NAME,
collation_catalog AS COLLATION_CATALOG,
collation_schema AS COLLATION_SCHEMA,
collation_name AS COLLATION_NAME,
domain_catalog AS DOMAIN_CATALOG,
domain_schema AS DOMAIN_SCHEMA,
domain_name AS DOMAIN_NAME,
column_comment AS COLUMN_COMMENT,
column_type AS COLUMN_TYPE
FROM system.columns FROM system.columns

View File

@ -12,30 +12,43 @@ ATTACH VIEW key_column_usage
`referenced_table_schema` Nullable(String), `referenced_table_schema` Nullable(String),
`referenced_table_name` Nullable(String), `referenced_table_name` Nullable(String),
`referenced_column_name` Nullable(String), `referenced_column_name` Nullable(String),
`CONSTRAINT_CATALOG` Nullable(String) ALIAS constraint_catalog, `CONSTRAINT_CATALOG` Nullable(String),
`CONSTRAINT_SCHEMA` Nullable(String) ALIAS constraint_schema, `CONSTRAINT_SCHEMA` Nullable(String),
`CONSTRAINT_NAME` Nullable(String) ALIAS constraint_name, `CONSTRAINT_NAME` Nullable(String),
`TABLE_CATALOG` String ALIAS table_catalog, `TABLE_CATALOG` String,
`TABLE_SCHEMA` String ALIAS table_schema, `TABLE_SCHEMA` String,
`TABLE_NAME` String ALIAS table_name, `TABLE_NAME` String,
`COLUMN_NAME` Nullable(String) ALIAS column_name, `COLUMN_NAME` Nullable(String),
`ORDINAL_POSITION` UInt32 ALIAS ordinal_position, `ORDINAL_POSITION` UInt32,
`POSITION_IN_UNIQUE_CONSTRAINT` Nullable(UInt32) ALIAS position_in_unique_constraint, `POSITION_IN_UNIQUE_CONSTRAINT` Nullable(UInt32),
`REFERENCED_TABLE_SCHEMA` Nullable(String) ALIAS referenced_table_schema, `REFERENCED_TABLE_SCHEMA` Nullable(String),
`REFERENCED_TABLE_NAME` Nullable(String) ALIAS referenced_table_name, `REFERENCED_TABLE_NAME` Nullable(String),
`REFERENCED_COLUMN_NAME` Nullable(String) ALIAS referenced_column_name `REFERENCED_COLUMN_NAME` Nullable(String)
) AS ) AS
SELECT 'def' AS `constraint_catalog`, SELECT
database AS `constraint_schema`, 'def' AS constraint_catalog,
'PRIMARY' AS `constraint_name`, database AS constraint_schema,
'def' AS `table_catalog`, 'PRIMARY' AS constraint_name,
database AS `table_schema`, 'def' AS table_catalog,
table AS `table_name`, database AS table_schema,
name AS `column_name`, table AS table_name,
position AS `ordinal_position`, name AS column_name,
NULL AS `position_in_unique_constraint`, 1 AS ordinal_position,
NULL AS `referenced_table_schema`, NULL AS position_in_unique_constraint,
NULL AS `referenced_table_name`, NULL AS referenced_table_schema,
NULL AS `referenced_column_name` NULL AS referenced_table_name,
NULL AS referenced_column_name,
constraint_catalog AS CONSTRAINT_CATALOG,
constraint_schema AS CONSTRAINT_SCHEMA,
constraint_name AS CONSTRAINT_NAME,
table_catalog AS TABLE_CATALOG,
table_schema AS TABLE_SCHEMA,
table_name AS TABLE_NAME,
column_name AS COLUMN_NAME,
ordinal_position AS ORDINAL_POSITION,
position_in_unique_constraint AS POSITION_IN_UNIQUE_CONSTRAINT,
referenced_table_schema AS REFERENCED_TABLE_SCHEMA,
referenced_table_name AS REFERENCED_TABLE_NAME,
referenced_column_name AS REFERENCED_COLUMN_NAME
FROM system.columns FROM system.columns
WHERE is_in_primary_key; WHERE is_in_primary_key;

View File

@ -11,27 +11,39 @@ ATTACH VIEW referential_constraints
`delete_rule` String, `delete_rule` String,
`table_name` String, `table_name` String,
`referenced_table_name` String, `referenced_table_name` String,
`CONSTRAINT_CATALOG` String ALIAS constraint_catalog, `CONSTRAINT_CATALOG` String,
`CONSTRAINT_SCHEMA` String ALIAS constraint_schema, `CONSTRAINT_SCHEMA` String,
`CONSTRAINT_NAME` Nullable(String) ALIAS constraint_name, `CONSTRAINT_NAME` Nullable(String),
`UNIQUE_CONSTRAINT_CATALOG` String ALIAS unqiue_constraint_catalog, `UNIQUE_CONSTRAINT_CATALOG` String,
`UNIQUE_CONSTRAINT_SCHEMA` String ALIAS unqiue_constraint_schema, `UNIQUE_CONSTRAINT_SCHEMA` String,
`UNIQUE_CONSTRAINT_NAME` Nullable(String) ALIAS unqiue_constraint_name, `UNIQUE_CONSTRAINT_NAME` Nullable(String),
`MATCH_OPTION` String ALIAS match_option, `MATCH_OPTION` String,
`UPDATE_RULE` String ALIAS update_rule, `UPDATE_RULE` String,
`DELETE_RULE` String ALIAS delete_rule `DELETE_RULE` String,
`TABLE_NAME` String ALIAS table_name, `TABLE_NAME` String,
`REFERENCED_TABLE_NAME` String ALIAS referenced_table_name `REFERENCED_TABLE_NAME` String
) AS ) AS
SELECT '' AS `constraint_catalog`, SELECT
NULL AS `constraint_name`, '' AS constraint_catalog,
'' AS `constraint_schema`, NULL AS constraint_name,
'' AS `unique_constraint_catalog`, '' AS constraint_schema,
NULL AS `unique_constraint_name`, '' AS unique_constraint_catalog,
'' AS `unique_constraint_schema`, NULL AS unique_constraint_name,
'' AS `match_option`, '' AS unique_constraint_schema,
'' AS `update_rule`, '' AS match_option,
'' AS `delete_rule` '' AS update_rule,
'' AS `table_name`, '' AS delete_rule,
'' AS `referenced_table_name` '' AS table_name,
'' AS referenced_table_name,
constraint_catalog AS CONSTRAINT_CATALOG,
constraint_name AS CONSTRAINT_NAME,
constraint_schema AS CONSTRAINT_SCHEMA,
unique_constraint_catalog AS UNIQUE_CONSTRAINT_CATALOG,
unique_constraint_name AS UNIQUE_CONSTRAINT_NAME,
unique_constraint_schema AS UNIQUE_CONSTRAINT_SCHEMA,
match_option AS MATCH_OPTION,
update_rule AS UPDATE_RULE,
delete_rule AS DELETE_RULE,
table_name AS TABLE_NAME,
referenced_table_name AS REFERENCED_TABLE_NAME
WHERE false; -- make sure this view is always empty WHERE false; -- make sure this view is always empty

View File

@ -7,20 +7,27 @@ ATTACH VIEW schemata
`default_character_set_schema` Nullable(String), `default_character_set_schema` Nullable(String),
`default_character_set_name` Nullable(String), `default_character_set_name` Nullable(String),
`sql_path` Nullable(String), `sql_path` Nullable(String),
`CATALOG_NAME` String ALIAS catalog_name, `CATALOG_NAME` String,
`SCHEMA_NAME` String ALIAS schema_name, `SCHEMA_NAME` String,
`SCHEMA_OWNER` String ALIAS schema_owner, `SCHEMA_OWNER` String,
`DEFAULT_CHARACTER_SET_CATALOG` Nullable(String) ALIAS default_character_set_catalog, `DEFAULT_CHARACTER_SET_CATALOG` Nullable(String),
`DEFAULT_CHARACTER_SET_SCHEMA` Nullable(String) ALIAS default_character_set_schema, `DEFAULT_CHARACTER_SET_SCHEMA` Nullable(String),
`DEFAULT_CHARACTER_SET_NAME` Nullable(String) ALIAS default_character_set_name, `DEFAULT_CHARACTER_SET_NAME` Nullable(String),
`SQL_PATH` Nullable(String) ALIAS sql_path `SQL_PATH` Nullable(String)
) AS ) AS
SELECT SELECT
name AS catalog_name, name AS catalog_name,
name AS schema_name, name AS schema_name,
'default' AS schema_owner, 'default' AS schema_owner,
NULL AS default_character_set_catalog, NULL AS default_character_set_catalog,
NULL AS default_character_set_schema, NULL AS default_character_set_schema,
NULL AS default_character_set_name, NULL AS default_character_set_name,
NULL AS sql_path NULL AS sql_path,
catalog_name AS CATALOG_NAME,
schema_name AS SCHEMA_NAME,
schema_owner AS SCHEMA_OWNER,
default_character_set_catalog AS DEFAULT_CHARACTER_SET_CATALOG,
default_character_set_schema AS DEFAULT_CHARACTER_SET_SCHEMA,
default_character_set_name AS DEFAULT_CHARACTER_SET_NAME,
sql_path AS SQL_PATH
FROM system.databases FROM system.databases

View File

@ -6,23 +6,29 @@ ATTACH VIEW tables
`table_type` String, `table_type` String,
`table_collation` Nullable(String), `table_collation` Nullable(String),
`table_comment` Nullable(String), `table_comment` Nullable(String),
`TABLE_CATALOG` String ALIAS table_catalog, `TABLE_CATALOG` String,
`TABLE_SCHEMA` String ALIAS table_schema, `TABLE_SCHEMA` String,
`TABLE_NAME` String ALIAS table_name, `TABLE_NAME` String,
`TABLE_TYPE` String ALIAS table_type, `TABLE_TYPE` String,
`TABLE_COLLATION` Nullable(String) ALIAS table_collation, `TABLE_COLLATION` Nullable(String),
`TABLE_COMMENT` Nullable(String) ALIAS table_comment `TABLE_COMMENT` Nullable(String)
) AS ) AS
SELECT SELECT
database AS table_catalog, database AS table_catalog,
database AS table_schema, database AS table_schema,
name AS table_name, name AS table_name,
multiIf(is_temporary, 'LOCAL TEMPORARY', multiIf(is_temporary, 'LOCAL TEMPORARY',
engine LIKE '%View', 'VIEW', engine LIKE '%View', 'VIEW',
engine LIKE 'System%', 'SYSTEM VIEW', engine LIKE 'System%', 'SYSTEM VIEW',
has_own_data = 0, 'FOREIGN TABLE', has_own_data = 0, 'FOREIGN TABLE',
'BASE TABLE' 'BASE TABLE'
) AS table_type, ) AS table_type,
'utf8mb4' AS table_collation, 'utf8mb4_0900_ai_ci' AS table_collation,
comment AS table_comment comment AS table_comment,
table_catalog AS TABLE_CATALOG,
table_schema AS TABLE_SCHEMA,
table_name AS TABLE_NAME,
table_type AS TABLE_TYPE,
table_collation AS TABLE_COLLATION,
table_comment AS TABLE_COMMENT
FROM system.tables FROM system.tables

View File

@ -10,16 +10,16 @@ ATTACH VIEW views
`is_trigger_updatable` Enum8('NO' = 0, 'YES' = 1), `is_trigger_updatable` Enum8('NO' = 0, 'YES' = 1),
`is_trigger_deletable` Enum8('NO' = 0, 'YES' = 1), `is_trigger_deletable` Enum8('NO' = 0, 'YES' = 1),
`is_trigger_insertable_into` Enum8('NO' = 0, 'YES' = 1), `is_trigger_insertable_into` Enum8('NO' = 0, 'YES' = 1),
`TABLE_CATALOG` String ALIAS table_catalog, `TABLE_CATALOG` String,
`TABLE_SCHEMA` String ALIAS table_schema, `TABLE_SCHEMA` String,
`TABLE_NAME` String ALIAS table_name, `TABLE_NAME` String,
`VIEW_DEFINITION` String ALIAS view_definition, `VIEW_DEFINITION` String,
`CHECK_OPTION` String ALIAS check_option, `CHECK_OPTION` String,
`IS_UPDATABLE` Enum8('NO' = 0, 'YES' = 1) ALIAS is_updatable, `IS_UPDATABLE` Enum8('NO' = 0, 'YES' = 1),
`IS_INSERTABLE_INTO` Enum8('NO' = 0, 'YES' = 1) ALIAS is_insertable_into, `IS_INSERTABLE_INTO` Enum8('NO' = 0, 'YES' = 1),
`IS_TRIGGER_UPDATABLE` Enum8('NO' = 0, 'YES' = 1) ALIAS is_trigger_updatable, `IS_TRIGGER_UPDATABLE` Enum8('NO' = 0, 'YES' = 1),
`IS_TRIGGER_DELETABLE` Enum8('NO' = 0, 'YES' = 1) ALIAS is_trigger_deletable, `IS_TRIGGER_DELETABLE` Enum8('NO' = 0, 'YES' = 1),
`IS_TRIGGER_INSERTABLE_INTO` Enum8('NO' = 0, 'YES' = 1) ALIAS is_trigger_insertable_into `IS_TRIGGER_INSERTABLE_INTO` Enum8('NO' = 0, 'YES' = 1)
) AS ) AS
SELECT SELECT
database AS table_catalog, database AS table_catalog,
@ -31,6 +31,16 @@ SELECT
engine = 'MaterializedView' AS is_insertable_into, engine = 'MaterializedView' AS is_insertable_into,
0 AS is_trigger_updatable, 0 AS is_trigger_updatable,
0 AS is_trigger_deletable, 0 AS is_trigger_deletable,
0 AS is_trigger_insertable_into 0 AS is_trigger_insertable_into,
table_catalog AS TABLE_CATALOG,
table_schema AS TABLE_SCHEMA,
table_name AS TABLE_NAME,
view_definition AS VIEW_DEFINITION,
check_option AS CHECK_OPTION,
is_updatable AS IS_UPDATABLE,
is_insertable_into AS IS_INSERTABLE_INTO,
is_trigger_updatable AS IS_TRIGGER_UPDATABLE,
is_trigger_deletable AS IS_TRIGGER_DELETABLE,
is_trigger_insertable_into AS IS_TRIGGER_INSERTABLE_INTO
FROM system.tables FROM system.tables
WHERE engine LIKE '%View' WHERE engine LIKE '%View'

View File

@ -1,37 +1,57 @@
COLUMNS COLUMNS
KEY_COLUMN_USAGE
REFERENTIAL_CONSTRAINTS
SCHEMATA SCHEMATA
TABLES TABLES
VIEWS VIEWS
columns columns
key_column_usage
referential_constraints
schemata schemata
tables tables
views views
COLUMNS COLUMNS
KEY_COLUMN_USAGE
REFERENTIAL_CONSTRAINTS
SCHEMATA SCHEMATA
TABLES TABLES
VIEWS VIEWS
columns columns
key_column_usage
referential_constraints
schemata schemata
tables tables
views views
INFORMATION_SCHEMA INFORMATION_SCHEMA default \N \N \N \N INFORMATION_SCHEMA INFORMATION_SCHEMA default \N \N \N \N
information_schema information_schema default \N \N \N \N information_schema information_schema default \N \N \N \N
default default mv VIEW default default kcu BASE TABLE utf8mb4_0900_ai_ci
default default t FOREIGN TABLE default default kcu2 BASE TABLE utf8mb4_0900_ai_ci
default default v VIEW default default mv VIEW utf8mb4_0900_ai_ci
tmp LOCAL TEMPORARY default default t FOREIGN TABLE utf8mb4_0900_ai_ci
default default v VIEW utf8mb4_0900_ai_ci
tmp LOCAL TEMPORARY utf8mb4_0900_ai_ci
default default mv SELECT * FROM system.one NONE NO YES NO NO NO default default mv SELECT * FROM system.one NONE NO YES NO NO NO
default default v SELECT n, f FROM default.t NONE NO NO NO NO NO default default v SELECT n, f FROM default.t NONE NO NO NO NO NO
default default mv default mv dummy 1 0 UInt8 \N \N 8 2 0 \N \N \N \N \N \N \N \N \N \N UInt8 default default kcu i 1 0 UInt32 \N \N 32 2 0 \N \N \N \N \N \N \N \N \N \N UInt32
default default t default t n 1 0 UInt64 \N \N 64 2 0 \N \N \N \N \N \N \N \N \N \N UInt64 default default kcu s 2 0 String \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N String
default default t default t f 2 0 Float32 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N Float32 default default kcu2 i 1 0 UInt32 \N \N 32 2 0 \N \N \N \N \N \N \N \N \N \N UInt32
default default t default t s 3 0 String \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N String default default kcu2 d 2 0 Date \N \N \N \N \N 0 \N \N \N \N \N \N \N \N \N Date
default default t default t fs 4 0 FixedString(42) 42 42 \N \N \N \N \N \N \N \N \N \N \N \N \N FixedString(42) default default kcu2 u 3 0 UUID \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N UUID
default default t default t d 5 0 Decimal(9, 6) \N \N 9 10 6 \N \N \N \N \N \N \N \N \N \N Decimal(9, 6) default default mv dummy 1 0 UInt8 \N \N 8 2 0 \N \N \N \N \N \N \N \N \N \N UInt8
default default v default v n 1 1 Nullable(Int32) \N \N 32 2 0 \N \N \N \N \N \N \N \N \N \N Nullable(Int32) default default t n 1 0 UInt64 \N \N 64 2 0 \N \N \N \N \N \N \N \N \N \N UInt64
default default v default v f 2 0 Float64 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N Float64 default default t f 2 0 Float32 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N Float32
tmp tmp d 1 0 Date \N \N \N \N \N 0 \N \N \N \N \N \N \N \N \N Date default default t s 3 0 String \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N String
tmp tmp dt 2 0 DateTime \N \N \N \N \N 0 \N \N \N \N \N \N \N \N \N DateTime default default t fs 4 0 FixedString(42) 42 42 \N \N \N \N \N \N \N \N \N \N \N \N \N FixedString(42)
tmp tmp dtms 3 0 DateTime64(3) \N \N \N \N \N 3 \N \N \N \N \N \N \N \N \N DateTime64(3) default default t d 5 0 Decimal(9, 6) \N \N 9 10 6 \N \N \N \N \N \N \N \N \N \N Decimal(9, 6)
default default v n 1 1 Nullable(Int32) \N \N 32 2 0 \N \N \N \N \N \N \N \N \N \N Nullable(Int32)
default default v f 2 0 Float64 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N Float64
tmp d 1 0 Date \N \N \N \N \N 0 \N \N \N \N \N \N \N \N \N Date
tmp dt 2 0 DateTime \N \N \N \N \N 0 \N \N \N \N \N \N \N \N \N DateTime
tmp dtms 3 0 DateTime64(3) \N \N \N \N \N 3 \N \N \N \N \N \N \N \N \N DateTime64(3)
1 1
1 1
def default PRIMARY def default kcu i 1 \N \N \N \N
def default PRIMARY def default kcu2 d 1 \N \N \N \N
def default PRIMARY def default kcu2 u 1 \N \N \N \N
def default PRIMARY def default kcu2 d 1 \N \N \N \N
def default PRIMARY def default kcu2 u 1 \N \N \N \N

View File

@ -5,20 +5,82 @@ DROP TABLE IF EXISTS t;
DROP VIEW IF EXISTS v; DROP VIEW IF EXISTS v;
DROP VIEW IF EXISTS mv; DROP VIEW IF EXISTS mv;
DROP TABLE IF EXISTS tmp; DROP TABLE IF EXISTS tmp;
DROP TABLE IF EXISTS kcu;
DROP TABLE IF EXISTS kcu2;
CREATE TABLE t (n UInt64, f Float32, s String, fs FixedString(42), d Decimal(9, 6)) ENGINE=Memory; CREATE TABLE t (n UInt64, f Float32, s String, fs FixedString(42), d Decimal(9, 6)) ENGINE=Memory;
CREATE VIEW v (n Nullable(Int32), f Float64) AS SELECT n, f FROM t; 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; CREATE MATERIALIZED VIEW mv ENGINE=Null AS SELECT * FROM system.one;
CREATE TEMPORARY TABLE tmp (d Date, dt DateTime, dtms DateTime64(3)); CREATE TEMPORARY TABLE tmp (d Date, dt DateTime, dtms DateTime64(3));
CREATE TABLE kcu (i UInt32, s String) ENGINE MergeTree ORDER BY i;
CREATE TABLE kcu2 (i UInt32, d Date, u UUID) ENGINE MergeTree ORDER BY (u, d);
-- FIXME #28687 -- FIXME #28687
SELECT * FROM information_schema.schemata WHERE schema_name ilike 'information_schema'; SELECT catalog_name,
schema_name,
schema_owner,
default_character_set_catalog,
default_character_set_schema,
default_character_set_name,
sql_path
FROM information_schema.schemata
WHERE schema_name ilike 'information_schema';
-- SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA=currentDatabase() OR TABLE_SCHEMA='') AND TABLE_NAME NOT LIKE '%inner%'; -- SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA=currentDatabase() OR TABLE_SCHEMA='') AND TABLE_NAME NOT LIKE '%inner%';
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (table_schema=currentDatabase() OR table_schema='') AND table_name NOT LIKE '%inner%';
SELECT * FROM information_schema.views WHERE table_schema=currentDatabase(); SELECT table_catalog,
table_schema,
table_name,
table_type,
table_collation,
table_comment
FROM INFORMATION_SCHEMA.TABLES
WHERE (table_schema = currentDatabase() OR table_schema = '')
AND table_name NOT LIKE '%inner%';
SELECT table_catalog,
table_schema,
table_name,
view_definition,
check_option,
is_updatable,
is_insertable_into,
is_trigger_updatable,
is_trigger_deletable,
is_trigger_insertable_into
FROM information_schema.views
WHERE table_schema = currentDatabase();
-- SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE (TABLE_SCHEMA=currentDatabase() OR TABLE_SCHEMA='') AND TABLE_NAME NOT LIKE '%inner%'; -- SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE (TABLE_SCHEMA=currentDatabase() OR TABLE_SCHEMA='') AND TABLE_NAME NOT LIKE '%inner%';
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE (table_schema=currentDatabase() OR table_schema='') AND table_name NOT LIKE '%inner%';
SELECT table_catalog,
table_schema,
table_name,
column_name,
ordinal_position,
column_default,
is_nullable,
data_type,
character_maximum_length,
character_octet_length,
numeric_precision,
numeric_precision_radix,
numeric_scale,
datetime_precision,
character_set_catalog,
character_set_schema,
character_set_name,
collation_catalog,
collation_schema,
collation_name,
domain_catalog,
domain_schema,
domain_name,
column_comment,
column_type
FROM INFORMATION_SCHEMA.COLUMNS
WHERE (table_schema = currentDatabase() OR table_schema = '')
AND table_name NOT LIKE '%inner%';
-- mixed upper/lowercase schema and table name: -- mixed upper/lowercase schema and table name:
SELECT count() FROM information_schema.TABLES WHERE table_schema=currentDatabase() AND table_name = 't'; SELECT count() FROM information_schema.TABLES WHERE table_schema=currentDatabase() AND table_name = 't';
@ -26,6 +88,51 @@ SELECT count() FROM INFORMATION_SCHEMA.tables WHERE table_schema=currentDatabase
SELECT count() FROM INFORMATION_schema.tables WHERE table_schema=currentDatabase() AND table_name = 't'; -- { serverError UNKNOWN_DATABASE } SELECT count() FROM INFORMATION_schema.tables WHERE table_schema=currentDatabase() AND table_name = 't'; -- { serverError UNKNOWN_DATABASE }
SELECT count() FROM information_schema.taBLES WHERE table_schema=currentDatabase() AND table_name = 't'; -- { serverError UNKNOWN_TABLE } SELECT count() FROM information_schema.taBLES WHERE table_schema=currentDatabase() AND table_name = 't'; -- { serverError UNKNOWN_TABLE }
SELECT constraint_catalog,
constraint_schema,
constraint_name,
table_catalog,
table_schema,
table_name,
column_name,
ordinal_position,
position_in_unique_constraint,
referenced_table_schema,
referenced_table_name,
referenced_column_name
FROM information_schema.key_column_usage
WHERE table_name = 'kcu';
SELECT constraint_catalog,
constraint_schema,
constraint_name,
table_catalog,
table_schema,
table_name,
column_name,
ordinal_position,
position_in_unique_constraint,
referenced_table_schema,
referenced_table_name,
referenced_column_name
FROM information_schema.key_column_usage
WHERE table_name = 'kcu2';
SELECT constraint_catalog,
constraint_name,
constraint_schema,
unique_constraint_catalog,
unique_constraint_name,
unique_constraint_schema,
match_option,
update_rule,
delete_rule,
table_name,
referenced_table_name
FROM information_schema.referential_constraints;
drop view mv; drop view mv;
drop view v; drop view v;
drop table t; drop table t;
drop table kcu;
drop table kcu2;