当前位置:网站首页>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
边栏推荐
猜你喜欢
mysql学习笔记——利用动态SQL和Session变量实现一个公式或者计算器
DSPE-PEG-DBCO,DBCO-PEG-DSPE,磷脂-聚乙二醇-二苯并环辛炔科研实验用
【图像分类】2021-DeiT
Learning and Exploration-Introducing Baidu Statistics to the Website
餐饮供应链管理系统
小满nestjs(第一章 介绍nestjs)
Understand Chisel language. 32. Chisel advanced hardware generator (1) - parameterization in Chisel
荣耀互联对外开放,赋能智能硬件合作伙伴,促进全场景生态产品融合
租房小程序登顶码云热门
localhost,127.0.0.1,本机IP
随机推荐
NLP未来,路在何方?从学术前沿和业界热点谈起
《中国综合算力指数》《中国算力白皮书》《中国存力白皮书》《中国运力白皮书》在首届算力大会上重磅发出
Clearance sword refers to Offer——The sword refers to Offer II 010. and the sub-array of k
yarn详细入门教程
吃透Chisel语言.32.Chisel进阶之硬件生成器(一)——Chisel中的参数化
华为云计算HCIE之oceanstor仿真器的使用操作
小程序经典案例
正则过滤字符串中 script 标签
字节二面被问到mysql事务与锁问题,我蚌埠住了
【日记】mysql基本操作
【图像分类】2021-DeiT
C# Sqlite database construction and use skills
提高图片清晰度的快速方法?
两个对象相同数据赋值
R语言ggplot2可视化:使用ggpubr包的ggbarplot函数可视化柱状图、color参数指定柱状图的边框的色彩
下一代 AutoAI:从模型为中心,到数据为中心
CAS:474922-26-4,DSPE-PEG-NH2,DSPE-PEG-amine,磷脂-聚乙二醇-氨基供应
公司自用的国产API管理神器
2022年7月31日 暑假第三周总结
JWT主动校验Token是否过期