17,377
社区成员
发帖
与我相关
我的任务
分享
SQL> create table a(id int,name nvarchar2(20));
Table created.
SQL> create table b(id int,name nvarchar2(20));
Table created.
SQL> insert into a select 1,'a' from dual;
1 row created.
SQL> insert into a select 2,'b' from dual;
1 row created.
SQL> insert into a select 3,null from dual;
1 row created.
SQL> insert into b select 1,'A' from dual;
1 row created.
SQL> insert into b select 2,'B' from dual;
1 row created.
SQL> insert into b select 3,'C' from dual;
1 row created.
SQL> commit;
Commit complete.
SQL> select * from a;
ID NAME
---------- --------------------
1 a
2 b
3
SQL> select * from b;
ID NAME
---------- --------------------
1 A
2 B
3 C
SQL> update a set a.name=(select name from b where nvl(a.name,0)<>nvl(b.name,0) and a.id=b.id);
3 rows updated.
SQL> select * from a;
ID NAME
---------- --------------------
1 A
2 B
3 C