create or replace procedure dddd is begin update Cus_B a set (a.col1,a.col2,....) = (select col1,col2,...... from Cus_A where ID = a.ID); --上面的Sql要求ID唯一 insert into Cus_B(col1,col2,....) select col1,col2,..... from Cus_A where ID not in (select ID from Cus_B);end;
insert into cus_b values (select * from cus_a where id no in (select id from cus_b where cus_a.id=cus_b.id))update cus_b set name=(select name from cus_a where cus_a.id=cus_b.id) and address=(select address from cus_a where cus_a.id=cus_b.id)注意:id有重复值, 那更新就失败
is
begin
update Cus_B a
set (a.col1,a.col2,....) = (select col1,col2,......
from Cus_A
where ID = a.ID);
--上面的Sql要求ID唯一
insert into Cus_B(col1,col2,....)
select col1,col2,.....
from Cus_A
where ID not in (select ID from Cus_B);end;
另:如果你只需要执行一次这种操作,这段算法可以写在存储过程;如果你需要实时地进行这种操作,即一旦A表中数据有改变(修改、添加等),则就需要上述操作,那你可以将这段算法写在触发器里,这样,你就可以高枕无忧了。
所需代码编写方法请参考pl/sql语法部分。
*^_^*