当前位置:网站首页>clickhouse online and offline table
clickhouse online and offline table
2022-08-04 17:33:00 【High concurrency】
1.background
I like to drop the table directly when I delete the table. When I recently encountered the drop table, the table was being written or other operations were performed, which caused the deletion of the table to fail.The operation is stopped, and then go to delete.
2. Description
Offline: DETACH TABLE|VIEW|DICTIONARY [IF EXISTS] [db.]name [ON CLUSTER cluster] [PERMANENTLY]
Online: ATTACH TABLE|VIEW|DICTIONARY [IF EXISTS] [db.]name [ON CLUSTER cluster] [PERMANENTLY]
Official website translation:
Detach does not delete data or metadata for tables, materialized views, or dictionaries.If an entity is not permanently detached, the next time the server starts, the server will read the metadata and recall the table/view/dictionary again.If an entity is permanently detached, there will be no automatic recall.Regardless of whether the table or dictionary is permanently detached, in both cases they can be reattached using an ATTACH query.System log tables can also be appended to the back (eg query_log, text_log, etc.).Unable to reconnect other system tables.At the next server startup, the server will recall these tables again.ATTACH materialized views cannot use short syntax (no SELECT), but it can be attached using an ATTACH TABLE query.Note that already detached tables (temporarily) cannot be detached permanently.But you can take it back and separate it permanently.You also cannot DROP the detached table, or use a CREATE table with the same name as the detached table, or replace it with another table with a RENAME table query.
3. Action
# test tableCREATE TABLE IF NOT EXISTS test.test_uid_20220803(`uid` Int32,`deviceId` String)ENGINE = ReplicatedMergeTree('/clickhouse/test/tables/{shard}/test_uid_20220803', '{replica}')PARTITION BY uidORDER BY uidSETTINGS index_granularity = 8192;# Test DataINSERT INTO test.test_uid_20220803SELECT 1, 'abcd';
# logout tabledetach table test.test_uid_20220803;# Querying again will show that the table does not existSELECT count()FROM test.test_uid_20220803Received exception from server (version 21.3.15):Code: 60. DB::Exception: Received from 127.0.0.1:9000. DB::Exception: Table test.test_uid_20220803 doesn't exist.# Temporarily the table structure still exists, but it is hidden by ck and goes online againattach table test.test_uid_20220803;# delete tabledrop table test.test_uid_20220803;
Reference documentation: clickhouse official documentation
边栏推荐
猜你喜欢
随机推荐
如何让 JS 代码不可断点
88.(cesium之家)cesium聚合图
IDEA以多端口启动同一个服务项目
身为程序员的我们如何卷死别人?破局重生。
一张图片怎么旋转90度。利用ps
【论文阅读】Decision Transformer: Reinforcement Learning via Sequence Modeling
荣耀发布开发者服务平台,智慧生态合作提速
框架整合(二)- 使用Apache ShardingSphere实现数据分片
DMPE-PEG-Mal,二肉豆蔻酰磷脂酰乙醇胺-聚乙二醇-马来酰亚胺简述
小程序学习目标
MySQL学习笔记-4.数据更新时的性能问题
【MySQL】数据库的4中隔离级别
(1), the sequential storage structure of linear table chain storage structure
Digital-intelligent supply chain management system for chemical manufacturing industry: build a smart supply system and empower enterprises to improve production efficiency
树莓派温度监视关机保护脚本
C. LIS or Reverse LIS?
怎么面试程序员的?傲慢与无礼,就数他牛逼
arm交叉编译
树莓派连接蓝牙音箱
动态数组底层是如何实现的