A表
id password
1 123456
2 234567
3 345678B表
id password
1 1234
2 1234
3 1234
4 2233445如何用SQL语句实现 A表的数据覆盖掉B表id相同的记录行。要求最终B表的数据如下B表
id password
1 123456
2 234567
3 345678
4 2233445
id password
1 123456
2 234567
3 345678B表
id password
1 1234
2 1234
3 1234
4 2233445如何用SQL语句实现 A表的数据覆盖掉B表id相同的记录行。要求最终B表的数据如下B表
id password
1 123456
2 234567
3 345678
4 2233445
merge into B
using A
on (B.id=A.id)
when matched then
update
set password=A.password
when not matched then
insert
values(A.id,A.password);
--update from oracle中不可以,mssql才可以,下面的大多數都可以
delete B where exists (select * from A where A.id=B.id);
insert into B select * from A;