clickhouse分区管理

这篇教程,我们创建一个分区并对分区进行删除、修改、卸载、挂载等操作

目录

创建分区表

查看分区信息

手动合并分区

分区删除

清除分区内某一列数据

分区复制

卸载分区

装载分区


创建分区表

create table tb_partition(
	oid Int8,
	ctime DateTime,
	money Float64
)engine=MergeTree()
partition by toYYYYMM(ctime)
order by oid;

插入一些数据

insert into tb_partition values 
(1, '2022-02-05 13:22:12', 556.21), 
(2, '2022-03-04 15:18:47', 12.94), 
(3, '2022-03-16 17:58:14', 643.58);

查看分区信息

select table, partition, engine, path from system.parts where table = 'tb_partition';

手动合并分区

optimize table tb_partition;

分区删除

alter table tb_partition drop partition '202204';

清除分区内某一列数据

alter table tb_partition clear column money in partition 202202; 

分区复制

create table tb_partition_new2 as tb_partition;

alter table tb_partition_new2 replace partition 202202 from tb_partition;

卸载分区

alter table tb_partition detach partition 202202;

装载分区

alter table tb_partition attach partition 202202;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fanghailiang2016

扔个包子砸我一下吧~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值