資料泵的使用
資料泵使用
一 EXPDP 和IMPDP 使用說明
Oracle Database 10g引入了最新的資料泵(Data Dump)技術,資料泵匯出匯入(EXPDP和IMPDP)的作用
1)實現邏輯備份和邏輯恢復.
2)在資料庫使用者之間移動物件.
3)在資料庫之間移動物件
4)實現表空間搬移.
二 資料泵目錄的建立與授權
SQL> create directory chen_dir as '/home/oracle/chen';
目錄已建立。
SQL> grant read,write on directory chen_dir to scott;
授權成功。
SQL> revoke read,write on directory chen_dir from scott;
撤銷成功。
SQL> grant read,write on directory chen_dir to chen;
授權成功。
SQL> col owner for a5
SQL> col directory_name for a15
SQL> col directory_path for a40
SQL> select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
----- --------------- ----------------------------------------
SYS ADMIN_DIR /ade/aime_10.2_lnx_push/oracle/md/admin
SYS DATA_PUMP_DIR /opt/oracle/product/10.2.0/rdbms/log/
SYS WORK_DIR /ade/aime_10.2_lnx_push/oracle/work
SYS CHEN_DIR /home/oracle/chen
三 資料泵匯出
資料泵匯出包括:
1 匯出表
2 匯出方案
3 匯出表空間
4 匯出資料庫
1 資料泵按表匯出匯入
[oracle@localhost ~]$ expdp chen/chen directory=chen_dir tables=dept dumpfile=deptcc.dmp
Export: Release 10.2.0.1.0 - Production on 星期四, 23 4月, 2015 11:05:24
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: 操作無效
ORA-39070: 無法開啟日誌檔案。
ORA-29283: 檔案操作無效
ORA-06512: 在 "SYS.UTL_FILE", line 475
ORA-29283: 檔案操作無效
[oracle@localhost ~]$ mkdir chen
[oracle@localhost chen]$ expdp chen/chen directory=chen_dir tables=dept dumpfile=deptcc.dmp
Export: Release 10.2.0.1.0 - Production on 星期四, 23 4月, 2015 11:05:39
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
啟動 "CHEN"."SYS_EXPORT_TABLE_01": chen/******** directory=chen_dir tables=dept dumpfile=deptcc.dmp
正在使用 BLOCKS 方法進行估計...
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的總估計: 64 KB
處理物件型別 TABLE_EXPORT/TABLE/TABLE
處理物件型別 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 匯出了 "CHEN"."DEPT" 5.656 KB 4 行
已成功載入/解除安裝了主表 "CHEN"."SYS_EXPORT_TABLE_01"
******************************************************************************
CHEN.SYS_EXPORT_TABLE_01 的轉儲檔案集為:
/home/oracle/chen/deptcc.dmp
作業 "CHEN"."SYS_EXPORT_TABLE_01" 已於 11:05:55 成功完成
SQL> conn chen/chen
已連線。
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> drop table dept purge;
表已刪除。
SQL> select * from dept;
select * from dept
*
第 1 行出現錯誤:
ORA-00942: 表或檢視不存在
[oracle@localhost chen]$ impdp chen/chen directory=chen_dir tables=dept dumpfile=deptcc.dmp
Import: Release 10.2.0.1.0 - Production on 星期四, 23 4月, 2015 11:11:46
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已成功載入/解除安裝了主表 "CHEN"."SYS_IMPORT_TABLE_01"
啟動 "CHEN"."SYS_IMPORT_TABLE_01": chen/******** directory=chen_dir tables=dept dumpfile=deptcc.dmp
處理物件型別 TABLE_EXPORT/TABLE/TABLE
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
. . 匯入了 "CHEN"."DEPT" 5.656 KB 4 行
處理物件型別 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
作業 "CHEN"."SYS_IMPORT_TABLE_01" 已於 11:11:49 成功完成
SQL> conn chen/chen
已連線。
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
2 按方案( 使用者) 匯出
[oracle@localhost chen]$ expdp chen/chen directory=chen_dir schemas=chen dumpfile=chen.dmp
Export: Release 10.2.0.1.0 - Production on 星期四, 23 4月, 2015 13:11:12
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
啟動 "CHEN"."SYS_EXPORT_SCHEMA_01": chen/******** directory=chen_dir schemas=chen dumpfile=chen.dmp
正在使用 BLOCKS 方法進行估計...
處理物件型別 SCHEMA_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的總估計: 24.43 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
處理物件型別 SCHEMA_EXPORT/TABLE/INDEX/INDEX
處理物件型別 SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
處理物件型別 SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
處理物件型別 SCHEMA_EXPORT/TABLE/COMMENT
處理物件型別 SCHEMA_EXPORT/FUNCTION/FUNCTION
處理物件型別 SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
處理物件型別 SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 匯出了 "CHEN"."T1" 16.76 MB 640000 行
. . 匯出了 "CHEN"."TT" 1.785 MB 100000 行
. . 匯出了 "CHEN"."T2" 274.2 KB 10000 行
. . 匯出了 "CHEN"."T3" 274.2 KB 10000 行
. . 匯出了 "CHEN"."A1" 7.820 KB 14 行
. . 匯出了 "CHEN"."A2" 5.656 KB 4 行
. . 匯出了 "CHEN"."DEPT" 5.656 KB 4 行
. . 匯出了 "CHEN"."DEPT10" 7.382 KB 3 行
. . 匯出了 "CHEN"."DEPT20" 7.460 KB 5 行
. . 匯出了 "CHEN"."DEPT30" 7.515 KB 6 行
. . 匯出了 "CHEN"."EMP" 7.828 KB 14 行
. . 匯出了 "CHEN"."EMP0" 7.828 KB 14 行
. . 匯出了 "CHEN"."EMP1" 7.382 KB 3 行
. . 匯出了 "CHEN"."SALGRADE" 5.585 KB 5 行
. . 匯出了 "CHEN"."U" 7.507 KB 6 行
已成功載入/解除安裝了主表 "CHEN"."SYS_EXPORT_SCHEMA_01"
******************************************************************************
CHEN.SYS_EXPORT_SCHEMA_01 的轉儲檔案集為:
/home/oracle/chen/chen.dmp
作業 "CHEN"."SYS_EXPORT_SCHEMA_01" 已於 13:11:26 成功完成
3 按表空間匯出
SQL> chen/chen
已連線。
SQL> select default_tablespace from user_users;
DEFAULT_TABLESPACE
------------------------------
USERS
[oracle@localhost chen]$ expdp chen/chen directory=chen_dir dumpfile=chentabl.dmp logfile=tabl.log tablespaces=users
Export: Release 10.2.0.1.0 - Production on 星期四, 23 4月, 2015 13:17:21
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
啟動 "CHEN"."SYS_EXPORT_TABLESPACE_01": chen/******** directory=chen_dir dumpfile=chentabl.dmp logfile=tabl.log tablespaces=users
正在使用 BLOCKS 方法進行估計...
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的總估計: 4.829 GB
處理物件型別 TABLE_EXPORT/TABLE/TABLE
處理物件型別 TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/COMMENT
處理物件型別 TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
處理物件型別 TABLE_EXPORT/TABLE/TRIGGER
處理物件型別 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 匯出了 "REMS"."BM_TRANS" 693.4 MB 2066949 行
. . 匯出了 "KASYS"."HISTRAN" 58.28 KB 160 行
. . 匯出了 "KASYS_CMS"."HISTRAN" 45.01 KB 106 行
. . 匯出了 "NEWCARD"."HISTRAN" 28.82 KB 39 行
. . 匯出了 "KASYS_CMS"."CARDACCT" 24.23 MB 150240 行
…………..
已成功載入/解除安裝了主表 "CHEN"."SYS_EXPORT_TABLESPACE_01"
******************************************************************************
CHEN.SYS_EXPORT_TABLESPACE_01 的轉儲檔案集為:
/home/oracle/chen/chentabl.dmp
作業 "CHEN"."SYS_EXPORT_TABLESPACE_01" 已於 13:35:36 成功完成
4 全庫匯出
[oracle@localhost chen]$ expdp chen/chen directory=chen_dir dumpfile=full.dmp logfile=full.log full=y
注:如果提示使用者沒有相應的許可權,給使用者相應的許可權或使用system來做全庫匯出 。
SQL> grant exp_full_database to chen;
Export: Release 10.2.0.1.0 - Production on 星期四, 23 4月, 2015 13:40:35
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
啟動 "CHEN"."SYS_EXPORT_FULL_01": chen/******** directory=chen_dir dumpfile=full.dmp logfile=full.log full=y
正在使用 BLOCKS 方法進行估計...
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
使用 BLOCKS 方法的總估計: 4.847 GB
處理物件型別 DATABASE_EXPORT/TABLESPACE
處理物件型別 DATABASE_EXPORT/PROFILE
處理物件型別 DATABASE_EXPORT/SYS_USER/USER
……………
已成功載入/解除安裝了主表 "CHEN"."SYS_EXPORT_FULL_01"
******************************************************************************
CHEN.SYS_EXPORT_FULL_01 的轉儲檔案集為:
/home/oracle/chen/full.dmp
作業 "CHEN"."SYS_EXPORT_FULL_01" 已於 13:58:44 成功完成
四 資料泵匯入
資料泵匯入包括:
1 匯入表
2 匯入方案
3 匯入表空間
4 匯入資料庫
1 Impdp 按表匯入
SQL> conn chen/chen
已連線。
SQL> drop table dept purge;
表已刪除。
[oracle@localhost chen]$ impdp chen/chen directory=chen_dir dumpfile=full.dmp ta
bles=chen.dept remap_schema=chen:chen
Import: Release 10.2.0.1.0 - Production on 星期四, 23 4月, 2015 14:14:45
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已成功載入/解除安裝了主表 "CHEN"."SYS_IMPORT_TABLE_01"
啟動 "CHEN"."SYS_IMPORT_TABLE_01": chen/******** directory=chen_dir dumpfile=full.dmp tables=chen.dept remap_schema=chen:chen
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/TABLE
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
. . 匯入了 "CHEN"."DEPT" 5.656 KB 4 行
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
作業 "CHEN"."SYS_IMPORT_TABLE_01" 已於 14:16:09 成功完成
2 按方案( 使用者) 匯入
SQL> create user test identified by test;
使用者已建立。
SQL> grant connect,resource to test;
授權成功。
SQL> alter user test account unlock;
使用者已更改。
[oracle@localhost chen]$ impdp chen/chen directory=chen_dir dumpfile=full.dmp sc
hemas=chen remap_schema=chen:test
Import: Release 10.2.0.1.0 - Production on 星期四, 23 4月, 2015 14:35:47
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已成功載入/解除安裝了主表 "CHEN"."SYS_IMPORT_SCHEMA_01"
啟動 "CHEN"."SYS_IMPORT_SCHEMA_01": chen/******** directory=chen_dir dumpfile=full.dmp schemas=chen remap_schema=chen:test
處理物件型別 DATABASE_EXPORT/SCHEMA/USER
ORA-31684: 物件型別 USER:"TEST" 已存在
處理物件型別 DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT
處理物件型別 DATABASE_EXPORT/SCHEMA/ROLE_GRANT
處理物件型別 DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
處理物件型別 DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/TABLE
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
. . 匯入了 "TEST"."T1" 16.76 MB 640000 行
. . 匯入了 "TEST"."TT" 1.785 MB 100000 行
. . 匯入了 "TEST"."T2" 274.2 KB 10000 行
. . 匯入了 "TEST"."T3" 274.2 KB 10000 行
. . 匯入了 "TEST"."A1" 7.820 KB 14 行
. . 匯入了 "TEST"."A2" 5.656 KB 4 行
. . 匯入了 "TEST"."DEPT" 5.656 KB 4 行
. . 匯入了 "TEST"."DEPT10" 7.382 KB 3 行
. . 匯入了 "TEST"."DEPT20" 7.460 KB 5 行
. . 匯入了 "TEST"."DEPT30" 7.515 KB 6 行
. . 匯入了 "TEST"."EMP" 7.828 KB 14 行
. . 匯入了 "TEST"."EMP0" 7.828 KB 14 行
. . 匯入了 "TEST"."EMP1" 7.382 KB 3 行
. . 匯入了 "TEST"."SALGRADE" 5.585 KB 5 行
. . 匯入了 "TEST"."U" 7.507 KB 6 行
處理物件型別 DATABASE_EXPORT/SCHEMA/FUNCTION/FUNCTION
處理物件型別 DATABASE_EXPORT/SCHEMA/FUNCTION/ALTER_FUNCTION
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
作業 "CHEN"."SYS_IMPORT_SCHEMA_01" 已經完成, 但是有 1 個錯誤 (於 14:37:04 完成)
出現一個錯誤:因為使用者test 已經存在,不需要額外建立
[oracle@localhost chen]$ impdp chen/chen directory=chen_dir dumpfile=full.dmp sc
hemas=chen remap_schema=chen:chen008
其中資料庫中沒有chen008 使用者,匯入時自動建立使用者chen008, 其許可權,預設表空間和使用者chen 相同
如果要將表匯入到其他方案中, 必須指定REMAP SCHEMA 選項.
Import: Release 10.2.0.1.0 - Production on 星期四, 23 4月, 2015 14:41:27
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已成功載入/解除安裝了主表 "CHEN"."SYS_IMPORT_SCHEMA_01"
啟動 "CHEN"."SYS_IMPORT_SCHEMA_01": chen/******** directory=chen_dir dumpfile=full.dmp schemas=chen remap_schema=chen:chen008
處理物件型別 DATABASE_EXPORT/SCHEMA/USER
處理物件型別 DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT
處理物件型別 DATABASE_EXPORT/SCHEMA/ROLE_GRANT
處理物件型別 DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
處理物件型別 DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/TABLE
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
. . 匯入了 "CHEN008"."T1" 16.76 MB 640000 行
. . 匯入了 "CHEN008"."TT" 1.785 MB 100000 行
. . 匯入了 "CHEN008"."T2" 274.2 KB 10000 行
. . 匯入了 "CHEN008"."T3" 274.2 KB 10000 行
. . 匯入了 "CHEN008"."A1" 7.820 KB 14 行
. . 匯入了 "CHEN008"."A2" 5.656 KB 4 行
. . 匯入了 "CHEN008"."DEPT" 5.656 KB 4 行
. . 匯入了 "CHEN008"."DEPT10" 7.382 KB 3 行
. . 匯入了 "CHEN008"."DEPT20" 7.460 KB 5 行
. . 匯入了 "CHEN008"."DEPT30" 7.515 KB 6 行
. . 匯入了 "CHEN008"."EMP" 7.828 KB 14 行
. . 匯入了 "CHEN008"."EMP0" 7.828 KB 14 行
. . 匯入了 "CHEN008"."EMP1" 7.382 KB 3 行
. . 匯入了 "CHEN008"."SALGRADE" 5.585 KB 5 行
. . 匯入了 "CHEN008"."U" 7.507 KB 6 行
處理物件型別 DATABASE_EXPORT/SCHEMA/FUNCTION/FUNCTION
處理物件型別 DATABASE_EXPORT/SCHEMA/FUNCTION/ALTER_FUNCTION
處理物件型別 DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
作業 "CHEN"."SYS_IMPORT_SCHEMA_01" 已於 14:43:02 成功完成
SQL> conn /as sysdba
已連線。
SQL> alter user chen008 identified by chen008;
使用者已更改。
3 按表空間匯入
[oracle@localhost chen]$ impdp chen/chen directory=chen_dir dumpfile=full.dmp tablespace=users
4 按庫匯入
[oracle@localhost chen]$ impdp chen/chen directory=chen_dir dumpfile=full.dmp full=y
參考:
http://blog.csdn.net/jojo52013145/article/details/7966047
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-1593125/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 資料泵的使用Oracle
- 使用資料泵impdp匯入資料
- EXPDP 和 IMPDP 資料泵的使用_1
- EXPDP 和 IMPDP 資料泵的使用_2
- 資料泵 EXPDP 匯出工具的使用
- 資料泵IMPDP 匯入工具的使用
- 資料泵重建使用者
- EXPDP資料泵使用方法
- 資料泵
- 使用資料泵遷移遇到的問題
- 使用資料泵工具expdp工具匯出資料
- 使用資料泵(expdp、impdp)遷移資料庫流程資料庫
- 資料泵的TRANSFORM引數說明及使用ORM
- 三個使用資料泵(Data Pump)的小技巧
- 使用Oracle資料泵問題總結Oracle
- 詳說Oracle Vault——使用資料泵工具Oracle
- 使用資料泵匯出DDL語句
- expdp impdp Data Pump(資料泵)使用解析
- 資料泵造成的資料損失
- ORACLE 資料泵Oracle
- oracle資料泵Oracle
- 使用impdp,expdp資料泵進入海量資料遷移
- Exp和資料泵(Data Pump)的query引數使用
- 細緻入微:如何使用資料泵匯出表的部分列資料
- 12c 資料泵克隆使用者
- Oracle使用資料泵匯出匯入表Oracle
- ORACLE 10g資料泵使用說明Oracle 10g
- 殺停資料泵
- oracle 資料泵解析Oracle
- 資料泵 impdp 操作
- 資料泵檔案
- 資料泵小bug
- oracle之資料泵Oracle
- 使用oracle外部表進行資料泵解除安裝資料Oracle
- 資料泵引數檔案用於執行資料泵命令
- 【LOB】使用資料泵時 LOB 欄位存放位置
- Oracle使用資料泵 (expdp/impdp)實施遷移Oracle
- oracle 資料泵匯出簡單使用版Oracle