Oracle中可以同时运行两个事务吗?
我有一个方法
void SaveApplicationData()
{
begin transaction
update
insert
commit transaction
}
,如果两个用户同时调用这个方法,这两个数据库事务可以同时运行吗?
I have a method
void SaveApplicationData()
{
begin transaction
update
insert
commit transaction
}
if two users call this method at same time, can these two database transaction run at same time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
大量事务可以同时运行。但是,如果它们更新相同的行,则很可能会出现锁定问题,并且一个或多个行可能会回滚。 (我已经很长时间没有处理冲突的交易了。)
Large numbers of transactions can be running simultaneously. However, if they're updating the same rows, they may well have locking problems, and one or more may be rolled back. (It's a long time since I dealt with conflicting transactions.)
是的,他们可以同时运行
yes they can run at the same time
确保使用正确的隔离级别
Make sure of using the proper Isolation Level
不,它不能同时运行。假设您有一个帐户有 k 美元,并且在第一笔交易中您请求提取 k 美元,而在第二笔交易中您请求相同。您将获得 2 k 美元,因为您同时进行了交易,并且您的账户余额显示两次交易的 k 美元。所以避免这种情况,我认为他们使用同步。如果没有完成第一笔交易,您就无法进行第二笔交易,如果您进行,则必须等到第一笔交易完成。
No it cannot run at the same time. Let say u have an account having k dollars and in first transaction u requested to withdraw k dollars and in 2nd transaction u requested same. U will get 2 k dollars because u did transaction at same time and your account balance shows k dollars for both transaction. so avoid this i think they use synchronization. without completing the first transaction u cannot go for 2nd and if u go u have to wait till completion of first.