CitusDB:修改行的分区值是不允许的

问题描述:

我想更新或删除测试数据库上的数据使用基于postgressql的citus,请注意此信息: 不允许修改行的分区值 citus: 6.0 postgresql:9.6 当我使用citus时,如何删除或删除数据?CitusDB:修改行的分区值是不允许的

我认为这种情况下的错误信息有点令人困惑。不允许更新分发密钥值本身,但是,允许通过证明分发密钥值来更新/删除行。看下面的例子:

CREATE TABLE test_table (key int, value text); 

-- distribute the table 
SELECT create_distributed_table('test_table', 'key'); 

-- insert a row 
INSERT INTO test_table VALUES (1, 'some test'); 

-- get the inserted row 
SELECT * FROM test_table WHERE key = 1; 

-- now, update the row 
UPDATE test_table SET value = 'some another text' WHERE key = 1; 

-- get the updated row 
SELECT * FROM test_table WHERE key = 1; 

-- now delete the row 
DELETE FROM test_table WHERE key = 1; 

-- see that the row is delete 
SELECT * FROM test_table WHERE key = 1; 

现在,让我举一个不允许的例子。考虑到行已经基于该值被放置在分片上并且更新该值可能最终不在该分片中,所以不允许更新分发键值。

-- insert the row again 
INSERT INTO test_table VALUES (1, 'some test'); 

-- now, try to update the distribution key value 
UPDATE test_table SET key = 2 WHERE key = 1; 
ERROR: modifying the partition value of rows is not allowed 

希望这会有所帮助。

+0

它适合我。非常感谢 – Chan