今天要把遠程數據庫上的數據導入到本地數據庫,於是總結出以下幾種方法可供參考:
1.使用exp導出命令,導出指定的數據庫表以及數據,然後導入到本地數據庫中。(導入導出可參見前面的文章)
2.建立dblink,建立一個存儲過程,循環的寫入本地表中。
具體實現步驟:
>創建dblink
create database link EBS_TO_B2B.US.ORACLE.COM
connect to HANDOA(用戶名) identified by HANDOA(密碼)
using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.123.1.66)(PORT = 1521)) (CONNECT_DATA = (SID = fme)) )'(連接字符串);
檢測創建的dblink是否好使,
select * from fnd_territories_tl@b2b_to_ebs;
>創建存儲過程:
begin
for c in (select territory_code,
language,
territory_short_name,
created_by,
creation_date,
last_updated_by,
last_update_date,
last_update_login,
description,
source_lang
from fnd_territories_tl@b2b_to_ebs) loop
insert into bf_country_tl(COUNTRY_code, language, country_short_name,description,source_lang,CREATED_BY, CREATION_DATE,last_updated_by, last_update_date,
last_update_login)
values(c.territory_code,c.language,c.territory_short_name,c.description,c.source_lang,c.created_by,
c.creation_date,c.last_updated_by,c.last_update_date,c.last_update_login);
end loop;
end;
實現了遠程數據庫fnd_territories_tl表的數據到bf_country_tl數據的傳送。