oracle 多表关联更新为什么要加exists
2018-01-12 18:28
405 查看
SQL> create table t1(id int,name varchar2(10)); Table created. SQL> create table t2(id int,name varchar2(10)); Table created. SQL> insert into t1 values(1,'a'); 1 row created. SQL> insert into t1 values(2,'b'); 1 row created. SQL> insert into t2 values(3,'c'); 1 row created. SQL> insert into t2 values(2,'d'); 1 row created. SQL> select * from t1; ID NAME ---------- ---------- 1 a 2 b SQL> select * from t2; ID NAME ---------- ---------- 3 c 2 d SQL> update t1 set name =(select name from t2 where t1.id=t2.id); 2 rows updated. SQL> select * from t1; ID NAME ---------- ---------- 1 2 d SQL> delete from t1; 2 rows deleted. SQL> delete from t2; 2 rows deleted. SQL> insert into t1 values(1,'a'); 1 row created. SQL> insert into t1 values(2,'b'); 1 row created. SQL> insert into t2 values(3,'c'); 1 row created. SQL> insert into t2 values(2,'d'); 1 row created. SQL> update t1 set name =(select name from t2 where t1.id=t2.id) where exists(select 1 from t2 where t1.id=t2.id); 1 row updated. SQL> select * from t1; ID NAME ---------- ---------- 1 a 2 d
相关文章推荐
- Oracle 多表关联更新update
- mysql sql server oracle 都表关联更新
- 关联表的批量更新(ORACLE)
- Oracle Update多表关联更新
- oracle下表关联更新
- oracle的多表关联更新或者插入
- Oracle 两表关联更新
- SQL/Oracle 两表关联更新
- ORACLE 更新关联多张表
- Oracle多表关联更新
- ORACLE多表关联更新
- oracle多表关联更新
- UPDATE多表关联更新时为什么会慢
- Oracle如何在update中多表关联更新
- Oracle两张表关联批量更新其中一张表的数据
- Oracle多表关联更新(update多表关联)
- 【Oracle】两个表Join关联更新
- oracle 更新关联表数据
- 转 update关联更新在sqlserver和oracle中的实现
- Oracle多表关联更新(update多表关联)