将A表(EXCEL)的数据上传至B表(Oracle中的表):
1.将两张表有相同数据取A表的数据,更新B表的,用的是 关键字 intersect 实现 之后update B表
2.两张表有不同的数据,取A表的数据,添加到B表,用关键字minus 实现 之后 insert B表
3.今天发现一个特别的句子:
MERGE INTO [your table-name] [rename your table here] USING ( [write your query here] )[rename your query-sql and using just like a table] ON ([conditional expression here] AND [...]...) WHEN MATHED THEN [here you can execute some update sql or something else ] WHEN NOT MATHED THEN [execute something else here ! ]
例如:
merge into T_BHM_KC_CKXM b
using (select to_date(sx_date,'yyyy/mm/dd') sx,test_id from test_temp where sx_date is not null ) a
on (a.test_id=b.id)
when matched then
update set b.sx_date=a.sx
这个语句可以实现:根据a表的test_id 和 b表的id 进行匹配,如果两个值相等,把a表的sx_date 替换b表的sx_date。
很是6666