2016-07-07 48 views
-1

我有兩個地址表,如:A1與街,城市,建築和其他一個A2與這三列和其他人。表沒有相同的結構,A1沒有主鍵,我不能添加一個,因爲不在我的數據庫。從字符串列上的兩個表的Oracle同步數據

所以,我想要插入所有不在A2中的數據,比較STREET,CITY和BUILDING列。

我該怎麼做,因爲oracle.I中字符串列的比較非常慢,我注意到我有很多數據。 我可以用批處理和bulkinsert做這個嗎?

謝謝

+0

插入數據?如果是,那麼其他列的值應該是什麼?空值? – Utsav

+0

是的,我想插入數據到A2 –

+0

不理解的東西 - 如果問題是字符串比較在Oracle中非常慢,批處理和bulkinsert會如何幫助?他們如何加快字符串比較? – mathguy

回答

0

更新:嘗試合併,基本上做同樣的事情。另請參閱是否可以在連接條件中的列上創建索引,這可以提高性能。

MERGE INTO A2 
    USING A1 
    ON (a1.street=a2.street and a1.city=a2.city and a1.building=a2.building) 
    WHEN NOT MATCHED THEN 
    INSERT (Street,City,Building) 
    VALUES (a1.Street,a1.City,a1.Building); 

上:在A2

insert into A2 (Street,City,Building) 
select a1.Street,a1.City,a1.Building 
from a1 left join a2 
on a1.street=a2.street and a1.city=a2.city and a1.building=a2.building 
where a2.street is null and a2.city is null and a2.building is null 
+0

我已經這樣做,但它仍然很慢 –

+0

它仍然工作緩慢:( –

相關問題