由于12c引入了PDB概念,所以导出导入可以对单个PDB进行表级,用户级别,全库(PDB)导出。
注意:12C不支持CDB级别的任何导出,导入操作。
官方文档说明:
Note:
In Oracle Database 12c Release 1 (12.1), Data Pump does not support any CDB-wide operations. Data Pump issues the following warning if you are connected to the root or seed database of a CDB:
ORA-39357: WARNING: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.
测试:
查看PDB
SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 ZHIXIN READ WRITE NO 4 ZHIXIN2 READ WRITE NO 5 ZHIXIN4 READ WRITE NO
1.PDB导出表
SQL> create table zx as select * from all_objects; Table created. SQL> create directory zx as ‘/u01/dump/‘; Directory created. SQL> create user zx identified by zx; User created. SQL> grant dba,create session,resource,connect to zx; Grant succeeded.
[[email protected] ~]$ expdp zx/[email protected] directory=zx tables=zx dumpfile=zx.dump logfile=export.log Export: Release 12.1.0.2.0 - Production on Wed Aug 10 15:33:48 2016 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options Starting "ZX"."SYS_EXPORT_TABLE_01": zx/********@zhixin directory=zx tables=zx dumpfile=zx.dump logfile=export.log Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 12 MB Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER . . exported "ZX"."ZX" 10.18 MB 89150 rows Master table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for ZX.SYS_EXPORT_TABLE_01 is: /u01/dump/zx.dump Job "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Wed Aug 10 15:34:35 2016 elapsed 0 00:00:36
需要先配置一下service name
查看备份文件
[[email protected] ~]$ ll /u01/dump/ total 10592 -rw-r--r-- 1 oracle asmadmin 1219 Aug 10 15:34 export.log -rw-r----- 1 oracle asmadmin 10842112 Aug 10 15:34 zx.dump
2.PDB全库导出
试着导出其他PDB看看
[[email protected] ~]$ expdp zx/[email protected] directory=zx full=y dumpfile=zhixinfull.dump logfile=export.log Export: Release 12.1.0.2.0 - Production on Wed Aug 10 15:39:09 2016 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. UDE-01017: operation generated ORACLE error 1017 ORA-01017: invalid username/password; logon denied
会提示没有该用户,zx只属于zhixin这个PDB数据库的。
导出zhixin PDB全库
[[email protected] ~]$ expdp zx/[email protected] directory=zx full=y dumpfile=zhixinfull.dump logfile=export.log Export: Release 12.1.0.2.0 - Production on Wed Aug 10 15:39:50 2016 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options Starting "ZX"."SYS_EXPORT_FULL_01": zx/********@zhixin directory=zx full=y dumpfile=zhixinfull.dump .......省略 . . exported "SYS"."NACL$_WALLET_EXP" 0 KB 0 rows . . exported "WMSYS"."WM$EXP_MAP" 7.718 KB 3 rows . . exported "ZX"."ZX" 10.18 MB 89150 rows Master table "ZX"."SYS_EXPORT_FULL_01" successfully loaded/unloaded ****************************************************************************** Dump file set for ZX.SYS_EXPORT_FULL_01 is: /u01/dump/zhixinfull.dump Job "ZX"."SYS_EXPORT_FULL_01" successfully completed at Wed Aug 10 15:42:25 2016 elapsed 0 00:02:24
成功。
3.CDB表导出
建个用户
SQL> create user c##zx identified by zx; User created. SQL> grant dba to c##zx; Grant succeeded.
创建directory
SQL> create directory zxdump as ‘/u01/dump01/‘; Directory created.
3.1不指定PDB导出PDB中的表
[[email protected] ~]$ expdp c##zx/zx directory=zxdump tables=zx.zx dumpfile=zx%U.dump logfile=export.log Export: Release 12.1.0.2.0 - Production on Wed Aug 10 15:45:41 2016 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options ORA-39001: invalid argument value ORA-39195: At least one schema in the TABLE_FILTER does not exist.
提示用户不存在
[[email protected] ~]$ oerr ora 39195 39195, 00000, "At least one schema in the TABLE_FILTER does not exist." // *Cause: The TABLE_FITER specified contains a schema that does not exist. // *Action: Retry the job specifying only schemas that exist.
3.2指定PDB导出PDB中的表
[[email protected] ~]$ expdp c##zx/[email protected] directory=zx tables=zx.zx dumpfile=zx%U.dump logfile=export.log Export: Release 12.1.0.2.0 - Production on Wed Aug 10 16:17:25 2016 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options Starting "C##ZX"."SYS_EXPORT_TABLE_01": c##zx/********@zhixin directory=zx tables=zx.zx dumpfile=zx%U.dump logfile=export.log Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 12 MB Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER . . exported "ZX"."ZX" 10.18 MB 89150 rows Master table "C##ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for C##ZX.SYS_EXPORT_TABLE_01 is: /u01/dump/zx01.dump Job "C##ZX"."SYS_EXPORT_TABLE_01" successfully completed at Wed Aug 10 16:17:56 2016 elapsed 0 00:00:22
3.3导出整个PDB zhixin
和在PDB级别导出整库是一个效果。
[[email protected] ~]$ expdp c##zx/[email protected] directory=zx full=y dumpfile=zxfull%U.dump logfile=export.log Export: Release 12.1.0.2.0 - Production on Wed Aug 10 16:20:45 2016 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options Starting "C##ZX"."SYS_EXPORT_FULL_01": c##zx/********@zhixin directory=zx full=y dumpfile=zxfull%U.dump logfile=export.log ........省略 . . exported "WMSYS"."WM$EXP_MAP" 7.718 KB 3 rows . . exported "ZX"."ZX" 10.18 MB 89150 rows Master table "C##ZX"."SYS_EXPORT_FULL_01" successfully loaded/unloaded ****************************************************************************** Dump file set for C##ZX.SYS_EXPORT_FULL_01 is: /u01/dump/zxfull01.dump Job "C##ZX"."SYS_EXPORT_FULL_01" successfully completed at Wed Aug 10 16:23:02 2016 elapsed 0 00:02:05
3.4导出整个CDB
注意:这里报错了,不支持CDB级别的导出操作
SQL> create or replace directory zxdump as ‘/u01/dump01‘; Directory created. [[email protected] ~]$ expdp c##zx/zx directory=zxdump full=y dumpfile=cdbfull%U.dump logfile=export.log Export: Release 12.1.0.2.0 - Production on Wed Aug 10 16:27:52 2016 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options WARNING: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database. Starting "C##ZX"."SYS_EXPORT_FULL_02": c##zx/******** directory=zxdump full=y dumpfile=cdbfull%U.dump logfile=export.log .......省略 . . exported "C##SOE"."WAREHOUSES" 0 KB 0 rows Master table "C##ZX"."SYS_EXPORT_FULL_02" successfully loaded/unloaded ****************************************************************************** Dump file set for C##ZX.SYS_EXPORT_FULL_02 is: /u01/dump01/cdbfull01.dump Job "C##ZX"."SYS_EXPORT_FULL_02" completed with 1 error(s) at Wed Aug 10 16:30:03 2016 elapsed 0 00:02:09 转:http://www.cndba.cn/Expect-le/article/141
时间: 2024-10-08 10:28:34