oracle通过一个表更新另一个表

来自 http://www.blogjava.net/menglikun/archive/2007/11/23/134020.html
declare
       cursor t1 is select * from a;
begin
     for rec in t1 loop
         update b t set t.name=rec.name where t.id=rec.id;
     end loop;
end; 



完整的
create table A
(
id int,
name varchar(20)
)
create table B
(
id int,
name varchar(20)
)

insert into A values(1,'hao')
insert into A values(2,'xue')
insert into A values(3,'zhang')
insert into A values(4,'lei')

insert into B values(1,'C')
insert into B values(2,'D')
insert into B values(3,'F')

select * from A
select * from B

declare
       cursor t1 is select * from a;
begin
     for rec in t1 loop
         update b t set t.name=rec.name where t.id=rec.id;
     end loop;
end; 

你可能感兴趣的:(oracle,sql,C++,c,.net)