实现的是将a表中的a1 更换成b表中的b2,条件是a1 = b1,并且a1和b1都是唯一的。

 

update a  set a.a1=(select  b2 from a,b where a.a1=b.b1 )
where a.a1=(select   b1 from a,b where a.a1=b.b1 )

 

 

select * from a
select * from b

-- Create table
create table A
(
  A1 VARCHAR2(10),
  A2 VARCHAR2(10),
  A3 VARCHAR2(10)
)
tablespace FWZCGL
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64
    minextents 1
    maxextents unlimited
  );
 
 
  -- Create table
create table b
(
  b1 VARCHAR2(10),
  b2 VARCHAR2(10),
  b3 VARCHAR2(10)
)
tablespace FWZCGL
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64
    minextents 1
    maxextents unlimited
  );

posted on 2012-11-13 10:20  王玉涛  阅读(338)  评论(0编辑  收藏  举报