--如果所有的记录都匹配
update gsis_xw_bks set bylwf = (select bylwf from gsis_xw_bks_20130608 where gsis_xw_bks.resource_id = gsis_xw_bks_20130608.resource_id);
--如果存在不匹配的记录。
update gsis_Xw_bks set bylwf = (select bylwf from gsis_xw_bks_20130608 where gsis_Xw_bks.resource_id = gsis_xw_bks_20130608.resource_id)
where resource_id in (select distinct AY_LOG_ID from gsis_xw_bks_20130608) ;
update gsis_xw_bks set bylwf = (select bylwf from gsis_xw_bks_20130608 where gsis_xw_bks.resource_id = gsis_xw_bks_20130608.resource_id);
--如果存在不匹配的记录。
update gsis_Xw_bks set bylwf = (select bylwf from gsis_xw_bks_20130608 where gsis_Xw_bks.resource_id = gsis_xw_bks_20130608.resource_id)
where resource_id in (select distinct AY_LOG_ID from gsis_xw_bks_20130608) ;
本文介绍了一种在两个不同数据库表之间进行记录同步的方法。通过使用 SQL 更新语句结合子查询来实现数据的一致性更新,特别适用于当两表结构相似且需保持数据同步的场景。

被折叠的 条评论
为什么被折叠?



