oracle中,-根据B表的新部门更改A表的旧部门
    create table A
(
  BADEPTID VARCHAR2(30) not null, --旧部门编码
  ID NUMBER not null
);
alter table A
  add constraint ID_PK primary key (ID);
create table B
(
  OLD_DEPT VARCHAR2(4000) not null,--旧部门编码
  NEW_DEPT VARCHAR2(200) not null  --新部门编码
);
alter table B
  add constraint TEMP_PK primary key (OLD_DEPT, NEW_DEPT);
--根据B表的新部门更改A表的旧部门
Update A aa 
    Set aa.badeptid = (Select ab.new_dept  From B ab Where ab.old_dept = aa.badeptid) 
    Where Exists (Select 1 From B ab Where ab.Old_dept = aa.badeptid);