for update
2017-04-10 14:22
78 查看
oracle中,当我们使用select for update时,oracle做了2件事。首先对该条记录加锁,然后对该表结构加锁。
For example, if you select a row from a table with the FOR UPDATE clause, two locks will be created. One lock is placed on the row(s) you selected (and this will be an exclusive lock; no one else can lock that specific row in exclusive mode). The other lock,
a ROW SHARE TABLE lock, is placed on the table itself. This will prevent other sessions from placing an exclusive lock on the table and thus prevent them from altering the structure of the table。
1、该记录加锁
select * from hr.employees where employee_id=206 for update;
这个是session 1
看session 2
看以看到session 2 hang了
2、表结构加锁
可以看到session 2修改表结构,hang了
For example, if you select a row from a table with the FOR UPDATE clause, two locks will be created. One lock is placed on the row(s) you selected (and this will be an exclusive lock; no one else can lock that specific row in exclusive mode). The other lock,
a ROW SHARE TABLE lock, is placed on the table itself. This will prevent other sessions from placing an exclusive lock on the table and thus prevent them from altering the structure of the table。
1、该记录加锁
select * from hr.employees where employee_id=206 for update;
这个是session 1
看session 2
看以看到session 2 hang了
2、表结构加锁
可以看到session 2修改表结构,hang了
相关文章推荐
- for update 和 for update nowait 区别
- for update 与where current of的问题
- [每日一题] 11gOCP 1z0-052 :2013-09-25 Lock ――for update.................................C23
- For update 与For update of 的区别
- Oracle 之 for update 与for update skip locked
- 数据库:Mysql中“select ... for update”排他锁分析
- mysql的行锁,for update使用。
- for update 和 for update nowait的区别
- 关于 for update
- oracle for update和for update nowait
- Mysql 锁表 for update (引擎/事务)
- for update...
- oracle 锁表、解锁的语句 for update 死锁处理
- 数据库:Mysql中“select ... for update”排他锁分析
- 关于Oracle的读一致性与for update的一个问题
- for update 和 for update of 有什么区别
- 游标中的for update好处。(摘录)
- SELECT语句中的for update的用法
- 深入理解SELECT ... LOCK IN SHARE MODE和SELECT ... FOR UPDATE
- MySQL的SELECT ...for update