首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

AB两个同构表,A表数据覆盖B表ID雷同的数据

2012-09-20 
AB两个同构表,A表数据覆盖B表ID相同的数据A表idpassword112345622345673345678B表idpassword1123421234312

AB两个同构表,A表数据覆盖B表ID相同的数据
A表
id password
1 123456
2 234567
3 345678

B表
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


[解决办法]

SQL code
merge into Busing Aon (B.id=A.id)when matched thenupdateset password=A.passwordwhen not matched theninsertvalues(A.id,A.password); 

热点排行