clickhouse - 点击屋:information_schema.KEY_COLUMN_USAGE
问题描述
在 MySQL 中,我们有 information_schema.KEY_COLUMN_USAGE。我们在哪里可以在 click house 中找到相同的信息?select * from information_schema.KEY_COLUMN_USAGE in MySQL,通过执行我们得到结果。我想知道 clickhouse 中给出相同结果的查询是什么。
解决方案
CH 提供了几种方法来获取有关表的元数据。
让我们创建测试表:
CREATE TABLE test_001
(
`id` Int32 CODEC(Delta, LZ4),
CONSTRAINT id_should_be_positive CHECK id > 0
)
ENGINE = MergeTree()
PARTITION BY tuple()
ORDER BY id
看看这些方法:
SELECT *
FROM system.tables
WHERE name = 'test_001'
FORMAT Vertical
/*
Row 1:
──────
database: default
name: test_001
uuid: 00000000-0000-0000-0000-000000000000
engine: MergeTree
is_temporary: 0
data_paths: ['/var/lib/clickhouse/data/default/test_001/']
metadata_path: /var/lib/clickhouse/metadata/default/test_001.sql
metadata_modification_time: 2020-07-21 12:42:07
dependencies_database: []
dependencies_table: []
create_table_query: CREATE TABLE default.test_001 (`id` Int32 CODEC(Delta(4), LZ4), CONSTRAINT id_should_be_positive CHECK id > 0) ENGINE = MergeTree() PARTITION BY tuple() ORDER BY id SETTINGS index_granularity = 8192
engine_full: MergeTree() PARTITION BY tuple() ORDER BY id SETTINGS index_granularity = 8192
partition_key: tuple()
sorting_key: id
primary_key: id
sampling_key:
storage_policy: default
total_rows: 0
total_bytes: 0
*/
SELECT *
FROM system.columns
WHERE table = 'test_001'
FORMAT Vertical
/*
Row 1:
──────
database: default
table: test_001
name: id
type: Int32
default_kind:
default_expression:
data_compressed_bytes: 0
data_uncompressed_bytes: 0
marks_bytes: 0
comment:
is_in_partition_key: 0
is_in_sorting_key: 1
is_in_primary_key: 1
is_in_sampling_key: 0
compression_codec: CODEC(Delta(4), LZ4)
*/
DESCRIBE TABLE test_001
/*
┌─name─┬─type──┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
│ id │ Int32 │ │ │ │ Delta(4), LZ4 │ │
└──────┴───────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘
*/
SHOW CREATE TABLE test_001
/*
┌─statement──────────────────────────────────────────┐
│ CREATE TABLE default.test_001
(
`id` Int32 CODEC(Delta(4), LZ4),
CONSTRAINT id_should_be_positive CHECK id > 0
)
ENGINE = MergeTree()
PARTITION BY tuple()
ORDER BY id
SETTINGS index_granularity = 8192 │
└─────────────────────────────────────────────────────┘
*/
推荐阅读
- http - IIS headerWaitTimeout ssems 对慢速 HTTP 标头攻击没有影响
- javascript - 如何制作带有可以在 p5js 中消失和重新出现的点的 2D 图案?
- python - 在另一台机器上保存后无法在 keras 中加载模型(形状不匹配)
- python - 在 debian 上部署到服务器后,Bot 在没有线程的情况下无法工作(telebot,python)
- c# - 程序不会列出第二个方法(Vypocetrychlosti2)
- android - 需要从热点断开设备的方法。(安卓)
- android - 离子电容器:更改应用名称、应用图标和应用加载屏幕
- php - oauth-private.key 在 laravel 中不存在或不可读
- javascript - 常量变量不出现在 Windows 对象中
- c - 减少我的 if 语句中的代码量的问题