本专栏全部文章 | https://blog.youkuaiyun.com/tonghu_note/category_11713514.html |
总目录 | https://blog.youkuaiyun.com/tonghu_note/article/details/124333034 |
来我的dou音 aa10246666, 看配套视频
一、实战环境
节点 cn_node1(协调节点,不存储数据) | postgresql 14.2 | 10.211.55.9 |
节点 worker1_node2(工作节点,存储数据) | postgresql 14.2 | 10.211.55.4 |
节点 worker2_node3(工作节点,存储数据) | postgresql 14.2 | 10.211.55.6 |
citus-10.2 / debian 9 |
二、SQL命令参考
1、分布表转为普通表
在cn节点,查看系统中现有的Citus表
d1=# select * from citus_tables;
table_name | citus_table_type | distribution_column | colocation_id | table_size | shard_count | table_owner | access_method
------------+------------------+---------------------+---------------+------------+-------------+-------------+---------------
t1 | distributed | id | 2 | 8512 kB | 32 | postgres | heap
t11 | distributed | id | 2 | 8512 kB | 32 | postgres | heap
t2 | reference | <none> | 1 | 13 MB | 1 | postgres | heap
t22 | reference | <none> | 1 | 13 MB | 1 | postgres | heap
(4 rows)
在cn节点,我们将以上的分布表t1在线改为普通表
d1=# SELECT undistribute_table('t1');
NOTICE: creating a new table for public.t1
NOTICE: moving the data of public.t1
NOTICE: dropping the old public.t1
NOTICE: renaming the new table to public.t1
undistribute_table
--------------------
(1 row)
在cn节点,再查看系统中现有的Citus表,可以看到表t1已经转为了普通表
d1=# select * from citus_tables;
table_name | citus_table_type | distribution_column | colocation_id | table_size | shard_count | table_owner | access_method
------------+------------------+---------------------+---------------+------------+-------------+-------------+---------------
t11