mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Create information_schema
Задокументировал information_schema.
This commit is contained in:
parent
3eed1f06ea
commit
6725dc2a16
@ -24,6 +24,11 @@ Columns:
|
|||||||
- `is_in_primary_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Flag that indicates whether the column is in the primary key expression.
|
- `is_in_primary_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Flag that indicates whether the column is in the primary key expression.
|
||||||
- `is_in_sampling_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Flag that indicates whether the column is in the sampling key expression.
|
- `is_in_sampling_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Flag that indicates whether the column is in the sampling key expression.
|
||||||
- `compression_codec` ([String](../../sql-reference/data-types/string.md)) — Compression codec name.
|
- `compression_codec` ([String](../../sql-reference/data-types/string.md)) — Compression codec name.
|
||||||
|
- `character_octet_length` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — Maximum length in bytes for binary data, character data, or text data and images.
|
||||||
|
- `numeric_precision` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — Accuracy of approximate numeric data, exact numeric data, integer data, or monetary data. Otherwise, the NULL value is returned.
|
||||||
|
- `numeric_precision_radix` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — The base of the number system is the accuracy of approximate numeric data, exact numeric data, integer data or monetary data. Otherwise, the NULL value is returned.
|
||||||
|
- `numeric_scale` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — The scale of approximate numeric data, exact numeric data, integer data, or monetary data. Otherwise, the NULL value is returned.
|
||||||
|
- `datetime_precision` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — Subtype code for `DateTime` and `ISO` interval data types. For other data types, the NULL value is returned.
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
@ -34,10 +39,11 @@ SELECT * FROM system.columns LIMIT 2 FORMAT Vertical;
|
|||||||
```text
|
```text
|
||||||
Row 1:
|
Row 1:
|
||||||
──────
|
──────
|
||||||
database: system
|
database: INFORMATION_SCHEMA
|
||||||
table: aggregate_function_combinators
|
table: COLUMNS
|
||||||
name: name
|
name: table_catalog
|
||||||
type: String
|
type: String
|
||||||
|
position: 1
|
||||||
default_kind:
|
default_kind:
|
||||||
default_expression:
|
default_expression:
|
||||||
data_compressed_bytes: 0
|
data_compressed_bytes: 0
|
||||||
@ -49,13 +55,19 @@ is_in_sorting_key: 0
|
|||||||
is_in_primary_key: 0
|
is_in_primary_key: 0
|
||||||
is_in_sampling_key: 0
|
is_in_sampling_key: 0
|
||||||
compression_codec:
|
compression_codec:
|
||||||
|
character_octet_length: ᴺᵁᴸᴸ
|
||||||
|
numeric_precision: ᴺᵁᴸᴸ
|
||||||
|
numeric_precision_radix: ᴺᵁᴸᴸ
|
||||||
|
numeric_scale: ᴺᵁᴸᴸ
|
||||||
|
datetime_precision: ᴺᵁᴸᴸ
|
||||||
|
|
||||||
Row 2:
|
Row 2:
|
||||||
──────
|
──────
|
||||||
database: system
|
database: INFORMATION_SCHEMA
|
||||||
table: aggregate_function_combinators
|
table: COLUMNS
|
||||||
name: is_internal
|
name: table_schema
|
||||||
type: UInt8
|
type: String
|
||||||
|
position: 2
|
||||||
default_kind:
|
default_kind:
|
||||||
default_expression:
|
default_expression:
|
||||||
data_compressed_bytes: 0
|
data_compressed_bytes: 0
|
||||||
@ -67,6 +79,11 @@ is_in_sorting_key: 0
|
|||||||
is_in_primary_key: 0
|
is_in_primary_key: 0
|
||||||
is_in_sampling_key: 0
|
is_in_sampling_key: 0
|
||||||
compression_codec:
|
compression_codec:
|
||||||
|
character_octet_length: ᴺᵁᴸᴸ
|
||||||
|
numeric_precision: ᴺᵁᴸᴸ
|
||||||
|
numeric_precision_radix: ᴺᵁᴸᴸ
|
||||||
|
numeric_scale: ᴺᵁᴸᴸ
|
||||||
|
datetime_precision: ᴺᵁᴸᴸ
|
||||||
```
|
```
|
||||||
|
|
||||||
The `system.columns` table contains the following columns (the column type is shown in brackets):
|
The `system.columns` table contains the following columns (the column type is shown in brackets):
|
||||||
|
@ -9,6 +9,7 @@ Columns:
|
|||||||
- `data_path` ([String](../../sql-reference/data-types/string.md)) — Data path.
|
- `data_path` ([String](../../sql-reference/data-types/string.md)) — Data path.
|
||||||
- `metadata_path` ([String](../../sql-reference/data-types/enum.md)) — Metadata path.
|
- `metadata_path` ([String](../../sql-reference/data-types/enum.md)) — Metadata path.
|
||||||
- `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — Database UUID.
|
- `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — Database UUID.
|
||||||
|
- `comment` ([String](../../sql-reference/data-types/enum.md)) — Database comment.
|
||||||
|
|
||||||
The `name` column from this system table is used for implementing the `SHOW DATABASES` query.
|
The `name` column from this system table is used for implementing the `SHOW DATABASES` query.
|
||||||
|
|
||||||
@ -17,22 +18,20 @@ The `name` column from this system table is used for implementing the `SHOW DATA
|
|||||||
Create a database.
|
Create a database.
|
||||||
|
|
||||||
``` sql
|
``` sql
|
||||||
CREATE DATABASE test
|
CREATE DATABASE test;
|
||||||
```
|
```
|
||||||
|
|
||||||
Check all of the available databases to the user.
|
Check all of the available databases to the user.
|
||||||
|
|
||||||
``` sql
|
``` sql
|
||||||
SELECT * FROM system.databases
|
SELECT * FROM system.databases;
|
||||||
```
|
```
|
||||||
|
|
||||||
``` text
|
``` text
|
||||||
┌─name───────────────────────────┬─engine─┬─data_path──────────────────┬─metadata_path───────────────────────────────────────────────────────┬─────────────────────────────────uuid─┐
|
┌─name───────────────┬─engine─┬─data_path──────────────────┬─metadata_path───────────────────────────────────────────────────────┬─uuid─────────────────────────────────┬─comment─┐
|
||||||
│ _temporary_and_external_tables │ Memory │ /var/lib/clickhouse/ │ │ 00000000-0000-0000-0000-000000000000 │
|
│ INFORMATION_SCHEMA │ Memory │ /var/lib/clickhouse/ │ │ 00000000-0000-0000-0000-000000000000 │ │
|
||||||
│ default │ Atomic │ /var/lib/clickhouse/store/ │ /var/lib/clickhouse/store/d31/d317b4bd-3595-4386-81ee-c2334694128a/ │ d317b4bd-3595-4386-81ee-c2334694128a │
|
│ default │ Atomic │ /var/lib/clickhouse/store/ │ /var/lib/clickhouse/store/d31/d317b4bd-3595-4386-81ee-c2334694128a/ │ 24363899-31d7-42a0-a436-389931d752a0 │ │
|
||||||
│ test │ Atomic │ /var/lib/clickhouse/store/ │ /var/lib/clickhouse/store/39b/39bf0cc5-4c06-4717-87fe-c75ff3bd8ebb/ │ 39bf0cc5-4c06-4717-87fe-c75ff3bd8ebb │
|
│ information_schema │ Memory │ /var/lib/clickhouse/ │ │ 00000000-0000-0000-0000-000000000000 │ │
|
||||||
│ system │ Atomic │ /var/lib/clickhouse/store/ │ /var/lib/clickhouse/store/1d1/1d1c869d-e465-4b1b-a51f-be033436ebf9/ │ 1d1c869d-e465-4b1b-a51f-be033436ebf9 │
|
│ system │ Atomic │ /var/lib/clickhouse/store/ │ /var/lib/clickhouse/store/1d1/1d1c869d-e465-4b1b-a51f-be033436ebf9/ │ 03e9f3d1-cc88-4a49-83e9-f3d1cc881a49 │ │
|
||||||
└────────────────────────────────┴────────┴────────────────────────────┴─────────────────────────────────────────────────────────────────────┴──────────────────────────────────────┘
|
└────────────────────┴────────┴────────────────────────────┴─────────────────────────────────────────────────────────────────────┴──────────────────────────────────────┴─────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
[Original article](https://clickhouse.tech/docs/en/operations/system-tables/databases) <!--hide-->
|
|
||||||
|
117
docs/en/operations/system-tables/information_schema.md
Normal file
117
docs/en/operations/system-tables/information_schema.md
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
# information_schema {#information-schema}
|
||||||
|
|
||||||
|
`INFORMATION_SCHEMA` (`information_schema`) is a system database that contains views. Using these views, you can get information about the metadata of database objects.
|
||||||
|
|
||||||
|
The structure and composition of system tables may change in different versions of the product, but the support of the `information_schema` makes it possible to change the structure of system tables without changing the method of access to metadata. Metadata requests do not depend on the DBMS used.
|
||||||
|
|
||||||
|
``` sql
|
||||||
|
SHOW TABLES FROM INFORMATION_SCHEMA;
|
||||||
|
```
|
||||||
|
|
||||||
|
``` text
|
||||||
|
┌─name─────┐
|
||||||
|
│ COLUMNS │
|
||||||
|
│ SCHEMATA │
|
||||||
|
│ TABLES │
|
||||||
|
│ VIEWS │
|
||||||
|
└──────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
`INFORMATION_SCHEMA` contains the following views:
|
||||||
|
|
||||||
|
- `SCHEMATA` — The view that can be used to get all the current database schemas.
|
||||||
|
|
||||||
|
``` sql
|
||||||
|
SELECT * FROM information_schema.schemata WHERE schema_name ILIKE 'information_schema' LIMIT 1 FORMAT Vertical;
|
||||||
|
```
|
||||||
|
|
||||||
|
``` text
|
||||||
|
Row 1:
|
||||||
|
──────
|
||||||
|
catalog_name: INFORMATION_SCHEMA
|
||||||
|
schema_name: INFORMATION_SCHEMA
|
||||||
|
schema_owner: default
|
||||||
|
default_character_set_catalog: ᴺᵁᴸᴸ
|
||||||
|
default_character_set_schema: ᴺᵁᴸᴸ
|
||||||
|
default_character_set_name: ᴺᵁᴸᴸ
|
||||||
|
sql_path: ᴺᵁᴸᴸ
|
||||||
|
```
|
||||||
|
|
||||||
|
- `TABLES` — The view that can be used to get all tables in the current database.
|
||||||
|
|
||||||
|
``` sql
|
||||||
|
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (table_schema = currentDatabase() OR table_schema = '') AND table_name NOT LIKE '%inner%' LIMIT 1 FORMAT Vertical;
|
||||||
|
```
|
||||||
|
|
||||||
|
``` text
|
||||||
|
Row 1:
|
||||||
|
──────
|
||||||
|
table_catalog: default
|
||||||
|
table_schema: default
|
||||||
|
table_name: describe_example
|
||||||
|
table_type: BASE TABLE
|
||||||
|
```
|
||||||
|
|
||||||
|
- `COLUMNS` — The view that can be used to get a list of table columns in the current database.
|
||||||
|
|
||||||
|
``` sql
|
||||||
|
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE (table_schema=currentDatabase() OR table_schema='') AND table_name NOT LIKE '%inner%' LIMIT 1 FORMAT Vertical;
|
||||||
|
```
|
||||||
|
|
||||||
|
``` text
|
||||||
|
Row 1:
|
||||||
|
──────
|
||||||
|
table_catalog: default
|
||||||
|
table_schema: default
|
||||||
|
table_name: describe_example
|
||||||
|
column_name: id
|
||||||
|
ordinal_position: 1
|
||||||
|
column_default:
|
||||||
|
is_nullable: 0
|
||||||
|
data_type: UInt64
|
||||||
|
character_maximum_length: ᴺᵁᴸᴸ
|
||||||
|
character_octet_length: ᴺᵁᴸᴸ
|
||||||
|
numeric_precision: 64
|
||||||
|
numeric_precision_radix: 2
|
||||||
|
numeric_scale: 0
|
||||||
|
datetime_precision: ᴺᵁᴸᴸ
|
||||||
|
character_set_catalog: ᴺᵁᴸᴸ
|
||||||
|
character_set_schema: ᴺᵁᴸᴸ
|
||||||
|
character_set_name: ᴺᵁᴸᴸ
|
||||||
|
collation_catalog: ᴺᵁᴸᴸ
|
||||||
|
collation_schema: ᴺᵁᴸᴸ
|
||||||
|
collation_name: ᴺᵁᴸᴸ
|
||||||
|
domain_catalog: ᴺᵁᴸᴸ
|
||||||
|
domain_schema: ᴺᵁᴸᴸ
|
||||||
|
domain_name: ᴺᵁᴸᴸ
|
||||||
|
```
|
||||||
|
|
||||||
|
- `VIEWS` — The view that can be used to get a list of all views in the current database.
|
||||||
|
|
||||||
|
``` 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 * FROM information_schema.views WHERE table_schema = currentDatabase();
|
||||||
|
```
|
||||||
|
|
||||||
|
``` text
|
||||||
|
Row 1:
|
||||||
|
──────
|
||||||
|
table_catalog: default
|
||||||
|
table_schema: default
|
||||||
|
table_name: mv
|
||||||
|
view_definition: SELECT * FROM system.one
|
||||||
|
check_option: NONE
|
||||||
|
is_updatable: NO
|
||||||
|
is_insertable_into: YES
|
||||||
|
is_trigger_updatable: NO
|
||||||
|
is_trigger_deletable: NO
|
||||||
|
is_trigger_insertable_into: NO
|
||||||
|
```
|
||||||
|
|
||||||
|
**See Also**
|
||||||
|
|
||||||
|
- [View](../../sql-reference/statements/create/view.md).
|
||||||
|
- [system.tables](../../operations/system-tables/tables.md).
|
||||||
|
- [system.columns](../../operations/system-tables/columns.md).
|
||||||
|
- [system.views](../../operations/system-tables/views.md).
|
@ -30,6 +30,8 @@ Columns:
|
|||||||
|
|
||||||
- `engine_full` ([String](../../sql-reference/data-types/string.md)) - Parameters of the table engine.
|
- `engine_full` ([String](../../sql-reference/data-types/string.md)) - Parameters of the table engine.
|
||||||
|
|
||||||
|
- `as_select` ([String](../../sql-reference/data-types/string.md)) - `SELECT` query for view.
|
||||||
|
|
||||||
- `partition_key` ([String](../../sql-reference/data-types/string.md)) - The partition key expression specified in the table.
|
- `partition_key` ([String](../../sql-reference/data-types/string.md)) - The partition key expression specified in the table.
|
||||||
|
|
||||||
- `sorting_key` ([String](../../sql-reference/data-types/string.md)) - The sorting key expression specified in the table.
|
- `sorting_key` ([String](../../sql-reference/data-types/string.md)) - The sorting key expression specified in the table.
|
||||||
@ -56,6 +58,7 @@ Columns:
|
|||||||
|
|
||||||
- `comment` ([String](../../sql-reference/data-types/string.md)) - The comment for the table.
|
- `comment` ([String](../../sql-reference/data-types/string.md)) - The comment for the table.
|
||||||
|
|
||||||
|
- `has_own_data` ([UInt8](../../sql-reference/data-types/int-uint.md)) - Flag that indicates whether the table itself stores some data on disk or only accesses some other source.
|
||||||
|
|
||||||
The `system.tables` table is used in `SHOW TABLES` query implementation.
|
The `system.tables` table is used in `SHOW TABLES` query implementation.
|
||||||
|
|
||||||
@ -80,6 +83,7 @@ dependencies_database: []
|
|||||||
dependencies_table: []
|
dependencies_table: []
|
||||||
create_table_query: CREATE TABLE base.t1 (`n` UInt64) ENGINE = MergeTree ORDER BY n SETTINGS index_granularity = 8192
|
create_table_query: CREATE TABLE base.t1 (`n` UInt64) ENGINE = MergeTree ORDER BY n SETTINGS index_granularity = 8192
|
||||||
engine_full: MergeTree ORDER BY n SETTINGS index_granularity = 8192
|
engine_full: MergeTree ORDER BY n SETTINGS index_granularity = 8192
|
||||||
|
as_select: SELECT database AS table_catalog
|
||||||
partition_key:
|
partition_key:
|
||||||
sorting_key: n
|
sorting_key: n
|
||||||
primary_key: n
|
primary_key: n
|
||||||
@ -90,6 +94,7 @@ total_bytes: 99
|
|||||||
lifetime_rows: ᴺᵁᴸᴸ
|
lifetime_rows: ᴺᵁᴸᴸ
|
||||||
lifetime_bytes: ᴺᵁᴸᴸ
|
lifetime_bytes: ᴺᵁᴸᴸ
|
||||||
comment:
|
comment:
|
||||||
|
has_own_data: 0
|
||||||
|
|
||||||
Row 2:
|
Row 2:
|
||||||
──────
|
──────
|
||||||
@ -105,6 +110,7 @@ dependencies_database: []
|
|||||||
dependencies_table: []
|
dependencies_table: []
|
||||||
create_table_query: CREATE TABLE default.`53r93yleapyears` (`id` Int8, `febdays` Int8) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 8192
|
create_table_query: CREATE TABLE default.`53r93yleapyears` (`id` Int8, `febdays` Int8) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 8192
|
||||||
engine_full: MergeTree ORDER BY id SETTINGS index_granularity = 8192
|
engine_full: MergeTree ORDER BY id SETTINGS index_granularity = 8192
|
||||||
|
as_select: SELECT name AS catalog_name
|
||||||
partition_key:
|
partition_key:
|
||||||
sorting_key: id
|
sorting_key: id
|
||||||
primary_key: id
|
primary_key: id
|
||||||
@ -115,6 +121,5 @@ total_bytes: 155
|
|||||||
lifetime_rows: ᴺᵁᴸᴸ
|
lifetime_rows: ᴺᵁᴸᴸ
|
||||||
lifetime_bytes: ᴺᵁᴸᴸ
|
lifetime_bytes: ᴺᵁᴸᴸ
|
||||||
comment:
|
comment:
|
||||||
|
has_own_data: 0
|
||||||
```
|
```
|
||||||
|
|
||||||
[Original article](https://clickhouse.tech/docs/en/operations/system-tables/tables) <!--hide-->
|
|
||||||
|
@ -173,7 +173,7 @@ roundBankers(4.5) = 4
|
|||||||
roundBankers(3.55, 1) = 3.6
|
roundBankers(3.55, 1) = 3.6
|
||||||
roundBankers(3.65, 1) = 3.6
|
roundBankers(3.65, 1) = 3.6
|
||||||
roundBankers(10.35, 1) = 10.4
|
roundBankers(10.35, 1) = 10.4
|
||||||
roundBankers(10.755, 2) = 11,76
|
roundBankers(10.755, 2) = 10,76
|
||||||
```
|
```
|
||||||
|
|
||||||
**Смотрите также**
|
**Смотрите также**
|
||||||
|
Loading…
Reference in New Issue
Block a user