我有一个大表测试,其中 user_id 2 有 500000 条记录。所以我想以 100 条记录为单位删除这条记录,但出现错误。这是我的查询:
delete from test where test_id in (select test_id
from test where User_id = 2 limit 100 )
Run Code Online (Sandbox Code Playgroud)
错误:元组同时更新
这是什么问题。我怎样才能解决它。
我有一个表,其中一列是自动递增序列号。我也希望将相同的值存储在另一列中(以便以后可以更改)。
我的表结构是这样的:
CREATE TABLE Test
(
test_id integer NOT NULL DEFAULT nextval('test_id_seq'::regclass),
...
...
uid integer not null DEFAULT currval('test_id_seq'::regclass),
)
Run Code Online (Sandbox Code Playgroud)
我想要uid = test_id但问题是在一个会话中插入多行时。然后currval不采取正确的ID。
我不想使用触发器。我该如何管理?