利用資料泵匯出遠端資料到本機資料庫!!!__資料庫

來源:互聯網
上載者:User

遠端資料庫使用者test下面有一張t表

SQL> show userUSER 為 "TEST"SQL> select * from tab;TNAME                          TABTYPE  CLUSTERID------------------------------ ------- ----------T                              TABLESQL> ! cat /etc/hosts# Do not remove the following line, or various programs# that require network functionality will fail.127.0.0.1       linux localhost.localdomain localhost::1             localhost6.localdomain6 localhost610.10.10.7      linux localhost.localdomain localhost
本機資料庫使用者ing下面沒有t表
SQL> show userUSER 為 "ING"SQL> select * from tab where tname = 'T';未選定行SQL> ! cat /etc/hosts# Do not remove the following line, or various programs# that require network functionality will fail.127.0.0.1       linux localhost.localdomain localhost::1             localhost6.localdomain6 localhost610.10.10.8      linux localhost.localdomain localhost10.10.10.8      linux10.10.10.8      localhost

現在要做的就是把使用者test下面的所有對象匯入到使用者ing下面。

1.建立一個資料庫連結化物件,連結到10.10.10.7的資料庫伺服器。

SQL> conn system/oracle已串連。SQL> show userUSER 為 "SYSTEM"SQL> create database link link7 connect to test identified by test using '10.10.10.7/orcl';資料庫連結已建立。SQL> select count(*) from test.t@link7;  COUNT(*)----------     50027

2.遠端資料10.10.10.7的使用者test必須具有exp_full_database許可權。

SQL> conn /as sysdba已串連。SQL> show userUSER 為 "SYS"SQL> grant exp_full_database to test;授權成功。

3.在10.10.10.8伺服器上面執行匯出。

[oracle@linux exp]$ expdp system/oracle@orcl network_link=link7 directory=exp schemas=testExport: Release 10.2.0.4.0 - Production on 星期三, 05 10月, 2011 19:48:57Copyright (c) 2003, 2007, Oracle.  All rights reserved.串連到: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options啟動 "SYSTEM"."SYS_EXPORT_SCHEMA_01":  system/********@orcl network_link=link7 directory=exp schemas=test 正在使用 BLOCKS 方法進行估計...處理物件類型 SCHEMA_EXPORT/TABLE/TABLE_DATA使用 BLOCKS 方法的總估計: 6 MB處理物件類型 SCHEMA_EXPORT/USER處理物件類型 SCHEMA_EXPORT/SYSTEM_GRANT處理物件類型 SCHEMA_EXPORT/ROLE_GRANT處理物件類型 SCHEMA_EXPORT/DEFAULT_ROLE處理物件類型 SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA處理物件類型 SCHEMA_EXPORT/TABLE/TABLE. . 匯出了 "TEST"."T"                                  4.667 MB   50027 行已成功載入/卸載了主表 "SYSTEM"."SYS_EXPORT_SCHEMA_01" ******************************************************************************SYSTEM.SYS_EXPORT_SCHEMA_01 的轉儲檔案集為:  /u01/exp/expdat.dmp作業 "SYSTEM"."SYS_EXPORT_SCHEMA_01" 已於 19:50:10 成功完成

4.在10.10.10.8伺服器上面執行匯入。

[oracle@linux exp]$ impdp system/oracle@orcl directory=exp dumpfile=expdat.dmp remap_schema=test:ingImport: Release 10.2.0.4.0 - Production on 星期三, 05 10月, 2011 19:51:24Copyright (c) 2003, 2007, Oracle.  All rights reserved.串連到: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options已成功載入/卸載了主表 "SYSTEM"."SYS_IMPORT_FULL_01" 啟動 "SYSTEM"."SYS_IMPORT_FULL_01":  system/********@orcl directory=exp dumpfile=expdat.dmp remap_schema=test:ing 處理物件類型 SCHEMA_EXPORT/USERORA-31684: 物件類型 USER:"ING" 已存在      --這裡沒有此使用者會自動建立。處理物件類型 SCHEMA_EXPORT/SYSTEM_GRANT處理物件類型 SCHEMA_EXPORT/ROLE_GRANT處理物件類型 SCHEMA_EXPORT/DEFAULT_ROLE處理物件類型 SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA處理物件類型 SCHEMA_EXPORT/TABLE/TABLE處理物件類型 SCHEMA_EXPORT/TABLE/TABLE_DATA. . 匯入了 "ING"."T"                                   4.667 MB   50027 行作業 "SYSTEM"."SYS_IMPORT_FULL_01" 已經完成, 但是有 1 個錯誤 (於 19:51:28 完成)

5.檢查10.10.10.8上面的使用者ing。

SQL> conn ing/ing已串連。SQL> show userUSER 為 "ING"SQL> select * from tab where tname = 'T';TNAME                          TABTYPE  CLUSTERID------------------------------ ------- ----------T                              TABLESQL> select count(*) from t;  COUNT(*)----------     50027
注意:匯入使用者要對錶空間使用不限制的權力:alter user ing quota unlimited on users; 這裡的system使用者當然有這個權力拉。對於小型資料庫可以這樣做,因為它要依賴網路。對於大型資料庫一般是在資料來源端匯出,然後拷貝到目標端執行匯入。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.