我在我的历史表中看到了重复的行-但是,首先更新它的事务会删除其中的数据;然后重新插入每个行的数据。其他查询都是正确的(并且在大多数情况下都能正常工作)。
为什么select语句可以看到不一致的数据视图?
create my_history_table (
`a` int(11),
`b` int(11),
`timestamp` datetime
) ENGINE=InnoDB;我们根据需要使用以下代码更新此表:
set autocommit=0;
set transaction isolation level read committed;
start transaction;
delete from my_history_table;
<loop on cursor inserting results for each>
commit;在另一个存储过程中,我们将这些结果读回给客户端:
select * from my_history_table join anotherTable using (a);发布于 2011-11-01 23:00:35
因此,答案是delete from;在获取锁时超时,但从MySQL 5.0.31开始,这不会自动回滚事务。所以它是在不做删除和提交的情况下进行插入。
https://stackoverflow.com/questions/7967994
复制相似问题