日期:2014-05-16 浏览次数:20785 次
create table TEST1 ( CODE VARCHAR2(20), NO VARCHAR2(20) )
create table TEST2 ( CODE VARCHAR2(20), NO VARCHAR2(20) )
insert into test1 (CODE, NO) values ('001001', '1'); insert into test1 (CODE, NO) values ('001001', '2'); insert into test1 (CODE, NO) values ('001001', '3'); insert into test2 (CODE, NO) values ('001001', ''); insert into test2 (CODE, NO) values ('001001', ''); insert into test2 (CODE, NO) values ('001001', '');
--增加辅助序号列 alter table test2 add (rn number); --更新序号值 update test2 set rn=rownum; --更新no UPDATE test2 a SET a.no = (SELECT b.no FROM (SELECT t.*, rownum rn FROM test1 t) b WHERE b.rn = a.rn); commit; --删除辅助序号列 alter table test2 drop column rn;