签到成功

知道了

CNDBA社区CNDBA社区

12C Export,Import使用

2016-09-02 12:18 5313 3 原创 Oracle 12C
作者: Expect-乐

由于12c引入了PDB概念,所以导出导入可以对单个PDB进行表级,用户级别,全库(PDB)导出。

http://www.cndba.cn/Expect-le/article/141
http://www.cndba.cn/Expect-le/article/141
http://www.cndba.cn/Expect-le/article/141

注意: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:http://www.cndba.cn/Expect-le/article/141

 

ORA-39357: WARNING: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.

测试:http://www.cndba.cn/Expect-le/article/141

查看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.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

查看备份文件

[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.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全库

[oracle@dg2 ~]$ expdp zx/zx@zhixin 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

成功。http://www.cndba.cn/Expect-le/article/141http://www.cndba.cn/Expect-le/article/141

3.CDB表导出

建个用户

SQL> create user c##zx identified by zx;
User created.
SQL> grant dba to c##zx;
Grant succeeded.

创建directoryhttp://www.cndba.cn/Expect-le/article/141http://www.cndba.cn/Expect-le/article/141

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.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.

提示用户不存在

[oracle@dg2 ~]$ 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中的表

[oracle@dg2 ~]$ expdp c##zx/zx@zhixin 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级别导出整库是一个效果。http://www.cndba.cn/Expect-le/article/141

[oracle@dg2 ~]$ expdp c##zx/zx@zhixin 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.
[oracle@dg2 ~]$ 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


版权声明:本文为博主原创文章,未经博主允许不得转载。

12c 导出导入

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
Expect-乐

Expect-乐

关注

Without the continuous bitter cold, there can be no fragrant plum blossom

  • 336
    原创
  • 6
    翻译
  • 100
    转载
  • 41
    评论
  • 访问:1363669次
  • 积分:1957
  • 等级:核心会员
  • 排名:第3名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ