select * from table_name for update; 和 select t.*, t.rowid from table_name t的区别
来源:互联网 发布:网络金融诈骗公司名单 编辑:程序博客网 时间:2024/05/16 06:00
select * from table_name for update; 和 select t.*, t.rowid from table_name t 的区别
前者会对你查询出来的结果加上锁,而后者就没有这样的机制;
此时如果有另一个session过来去对你结果集中的数据进行更新或者删除操作,则需要等到第一个事务提交或者回滚后,才能够执行该语句;
例如:
create table temp_yaosht(col1 varchar2(32));
insert into temp_yaosht values('a');
insert into temp_yaosht values('b');
insert into temp_yaosht values('c');
insert into temp_yaosht values('d');
insert into temp_yaosht values('e');
第一个session的sql语句
select *
from temp_yaosht
where col1 in ('a','b','c') for update;
第二session的sql语句
update temp_yaosht
set col1='aa'
where col1='a';
第三session的sql语句
update temp_yaosht
set col1='dd'
where col1='d';
先执行第一个sql语句;然后当我们执行第二个sql的时候,会发现sql一直处于执行状态,只有当第一个sql的事务提交之后,第二个sql才会执行,且结束。
第三个sql的执行并不受影响,因为第一个sql的只对‘a’,'b','c'这三条记录加了锁,而不是对该表加的锁。
select t.*, t.rowid from table_name t 则没有这样的限制。
- select * from table_name for update; 和 select t.*, t.rowid from table_name t的区别
- for update、for update nowait、select t.*,t.rowid from table的区别
- Oracle:for update 和select t.*,t.rowid编辑数据的区别
- You can't specify target table 'table_name' for update in FROM clause
- why 'select 1 from table_name'
- select count(column_name) form table_name or select count(*) from table_Name
- select * from t 和select * from t order by id两个有什么区别
- 使用JDBC获取select count(*) from table_name
- select table_name from all_tables where owner='ofbiz';
- SQL SERVER中的WITH T AS () SELECT * FROM T 的用法
- mysql中select column_name from Information_schema.columns where table_Name = 'test'出现多个字段的问题
- select replace(t.area_name,' ','') a from dic_area t where t.area_code = '131127'
- 有多少行? SELECT rows FROM sysindexes WHERE id = OBJECT_ID('table_name') AND indid < 2
- ‘select...(select...)... from’ 和‘select...from...inner join... ’的区别
- select count(*) from T 可以用到索引吗?
- ROWNUM用法--SELECT * FROM T WHERE ROWNUM=1
- mysql的1093错误You can't specify target table 't' for update in FROM clause 简单解决
- You can't specify target table 't' for update in FROM clause
- CNN卷积神经网络反向推导
- redis php sort 函数
- RESTful Web Services Part 1 - Definition
- 4.整数划分 (5分)
- open cv_1在windows下配置
- select * from table_name for update; 和 select t.*, t.rowid from table_name t的区别
- ios程序 引导屏
- Centos6.5下Oracle11g(x86)安装过程及图解
- CUDA在Windows下的软件开发环境搭建
- Android APK反编译详解(附图)
- CSDN怎么在顶端设置目录
- ArrayList和LinkedList的几种循环遍历方式及性能对比分析
- Android Studio下导入openCV到项目中
- Android中的Handler机制