怎么保证时间点的一致啊

写了多条select语句:
select * from master;
select * from detail1;
select * from detail2;
...
select * from detailn;

怎么保证这些表中的数据都是同一个时间点上的得到的一份镜像?

我对这些表都lock吗,有没有其他方法。
---------------------------------------------------------------

应当是
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
select * from master;
select * from detail1;
select * from detail2;
...
select * from detailn;

COMMIT;

oracle 提供三种isolation levels:read committed, serializable transactions, read-only。
"Serializable transactions see only those changes that were
committed at the time the transaction began, plus those
changes made by the transaction itself through INSERT,
UPDATE, and DELETE statements. Serializable transactions
do not experience nonrepeatable reads or phantoms."

我想使用lock的想法是同时lock所有要select 的表,然后发出select命令,再commit,之后慢慢fetch 数据。
使用SET TRANSACTION ISOLATION LEVEL SERIALIZABLE 可能更好些。

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus