Role: Merge into solution with B table and new a table data, if a table does not, then the B table data into a table;
Grammar:
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 isn't mathed THEN [execute something else here!]
-------instance-------
Merge into a
Using (select Id,name from B) c
On (a.id=c.id)
When matched then update set A.name=c.name
When not matched then insert (a.id,a.name) values (c.id,c.name);
Role: Use table B with new Table A, if the condition is a.id=b.id, if data in table A does not have that condition inserted.
If you have a large amount of data, this SQL efficiency is very high.
Author: 51cto Blog Oracle Little Bastard
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/