当前位置:网站首页>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
边栏推荐
猜你喜欢

OpenInfra Days China 2022|SelectDB与你共享 Apache Doris 在互联网广告业务中的实践

《中国综合算力指数》《中国算力白皮书》《中国存力白皮书》《中国运力白皮书》在首届算力大会上重磅发出

LeetCode Question of the Day - 1403. Minimum Subsequence in Non-Increasing Order

基于层次分析法的“内卷”指数分析

php如何查询字符串以什么开头

CAS:385437-57-0,DSPE-PEG-Biotin,生物活性分子磷脂-聚乙二醇-生物素

集群监控——Zabbix使用

codeforces每日5题(均1600)-第二十八天

如何模拟后台API调用场景,很细!

小程序笔记3
随机推荐
【日记】nodejs构建API框架以及RESTful API 和 JSON-RPC的取舍
JSP的Web监听器(Listener)
What does the product system of a digital financial enterprise look like?
树莓派温度监视关机保护脚本
dotnet core 隐藏控制台
华为云计算HCIE之oceanstor仿真器的安装教程
CAS:474922-26-4,DSPE-PEG-NH2,DSPE-PEG-amine,磷脂-聚乙二醇-氨基供应
动态数组底层是如何实现的
树莓派安装samba用来共享文件
字节二面被问到mysql事务与锁问题,我蚌埠住了
西西成语接龙小助手
我的大一.
框架整合(二)- 使用Apache ShardingSphere实现数据分片
JS中null与undefined的异同点
【无标题】
信息系统项目管理师必背核心考点(六十)项目集管理
使用Redis做某个时间段在线数统计
图扑软件与华为云共同构建新型智慧工厂
正则过滤字符串中 script 标签
dotnet remoting 抛出异常