首页 > 代码库 > 12C Export,Import使用
12C Export,Import使用
由于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.
[oracle@dg2 ~]$ expdp zx/zx@zhixin directory=zx tables=zx dumpfile=zx.dump logfile=export.logExport: Release 12.1.0.2.0 - Production on Wed Aug 10 15:33:48 2016Copyright (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 ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsStarting "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_DATATotal estimation using BLOCKS method: 12 MBProcessing object type TABLE_EXPORT/TABLE/TABLEProcessing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICSProcessing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER. . exported "ZX"."ZX" 10.18 MB 89150 rowsMaster table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded******************************************************************************Dump file set for ZX.SYS_EXPORT_TABLE_01 is: /u01/dump/zx.dumpJob "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Wed Aug 10 15:34:35 2016 elapsed 0 00:00:36
需要先配置一下service name
查看备份文件
[oracle@dg2 ~]$ 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看看
[oracle@dg2 ~]$ expdp zx/zx@zhixin2 directory=zx full=y dumpfile=zhixinfull.dump logfile=export.logExport: Release 12.1.0.2.0 - Production on Wed Aug 10 15:39:09 2016Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.UDE-01017: operation generated ORACLE error 1017ORA-01017: invalid username/password; logon denied
会提示没有该用户,zx只属于zhixin这个PDB数据库的。
导出zhixin PDB全库
[oracle@dg2 ~]$ expdp zx/zx@zhixin directory=zx full=y dumpfile=zhixinfull.dump logfile=export.logExport: Release 12.1.0.2.0 - Production on Wed Aug 10 15:39:50 2016Copyright (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 ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsStarting "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 rowsMaster table "ZX"."SYS_EXPORT_FULL_01" successfully loaded/unloaded******************************************************************************Dump file set for ZX.SYS_EXPORT_FULL_01 is: /u01/dump/zhixinfull.dumpJob "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中的表
[oracle@dg2 ~]$ expdp c##zx/zx directory=zxdump tables=zx.zx dumpfile=zx%U.dump logfile=export.logExport: Release 12.1.0.2.0 - Production on Wed Aug 10 15:45:41 2016Copyright (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 ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsORA-39001: invalid argument valueORA-39195: At least one schema in the TABLE_FILTER does not exist.
提示用户不存在
[oracle@dg2 ~]$ oerr ora 3919539195, 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中的表
[oracle@dg2 ~]$ expdp c##zx/zx@zhixin directory=zx tables=zx.zx dumpfile=zx%U.dump logfile=export.logExport: Release 12.1.0.2.0 - Production on Wed Aug 10 16:17:25 2016Copyright (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 ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsStarting "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_DATATotal estimation using BLOCKS method: 12 MBProcessing object type TABLE_EXPORT/TABLE/TABLEProcessing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICSProcessing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER. . exported "ZX"."ZX" 10.18 MB 89150 rowsMaster table "C##ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded******************************************************************************Dump file set for C##ZX.SYS_EXPORT_TABLE_01 is: /u01/dump/zx01.dumpJob "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级别导出整库是一个效果。
[oracle@dg2 ~]$ expdp c##zx/zx@zhixin directory=zx full=y dumpfile=zxfull%U.dump logfile=export.logExport: Release 12.1.0.2.0 - Production on Wed Aug 10 16:20:45 2016Copyright (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 ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsStarting "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 rowsMaster table "C##ZX"."SYS_EXPORT_FULL_01" successfully loaded/unloaded******************************************************************************Dump file set for C##ZX.SYS_EXPORT_FULL_01 is: /u01/dump/zxfull01.dumpJob "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.[oracle@dg2 ~]$ expdp c##zx/zx directory=zxdump full=y dumpfile=cdbfull%U.dump logfile=export.logExport: Release 12.1.0.2.0 - Production on Wed Aug 10 16:27:52 2016Copyright (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 ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsWARNING: 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 rowsMaster table "C##ZX"."SYS_EXPORT_FULL_02" successfully loaded/unloaded******************************************************************************Dump file set for C##ZX.SYS_EXPORT_FULL_02 is: /u01/dump01/cdbfull01.dumpJob "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
12C Export,Import使用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。