I am copy data from SQL Server to Oracle with a SSIS package, and I want to improve performance of copying with incremental updating.
My idea is to :
- Append new records of table.(delete them before then append)
- Delete "Deleted" records
Code:
drop table A1
drop table A2
--Old Table
create Table A1(id int,
a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int)
--New Table
create Table A2(id int,
a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int)
insert into A1 (id, a1, a2, a3, a4, a5, a6, a7, a8)
values (1,1,2,3,4,5,6,7,8), (2,2,2,5,4,2,6,2,8), (3,3,2,5,4,5,4,3,8),
(4,3,1,3,4,5,7,3,8)
insert into A2 (id, a1, a2, a3, a4, a5, a6, a7, a8)
values (1,2,2,3,4,5,6,7,8), (2,2,2,5,4,2,6,2,8), (3,3,2,5,4,5,4,3,8)
--1) Changed values
select * from a2
except
select * from a1;
--2) "Deleted" Values. If I Have primary key in A1,A2 the result is simply get by query
select a1.*
from A1
left join A2 on a2.id = a1.id
where a2.id is null
But I don't have a primary key on my tables in my real situation. How I can achieve 2 point by another way, without join by primary key ?
Result of query:
id a1 a2 a3 a4 a5 a6 a7 a8
1 2 2 3 4 5 6 7 8
id a1 a2 a3 a4 a5 a6 a7 a8
4 3 1 3 4 5 7 3 8