create table t1(
sid integer,
sname varchar2(32),
);
alter table t1 modify gender varchar2(3);
alter table t1 modify sname varchar2(30);
create table t2(
sid integer,
sname varchar2(32)
);
alter table t1 rename column sid to dsi;
insert into t1 values(1,'hello_what');
insert into t1 values(2,'hi');
insert into t2 values(1,'hello');
commit;
select * from t1;
select * from t2;
merge into t2
using (select * from t1) t1
on (t1.dsi = t2.sid)
when matched then update set t2.sname = t1.sname
delete where t2.sid = 1
when not matched then insert (sid,sname) values(t1.dsi,t1.sname)
merge的用法
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)