oracle12c在一个容器cdb中以多租户的形式同时存在多个数据库pdb,所以跟12c之前的导出略有不同
源库与目标库必须有针对导入导出pdb的tns配置
源库操作
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SYS@shgxdb>alter session set container=esb;
Session altered.
SYS@shgxdb>select owner, table_name from dba_tables where owner='ESBDB';
OWNER
--------------------------------------------------------------------------------
TABLE_NAME
--------------------------------------------------------------------------------
ESBDB
EOS_QRTZ_TRIGGERS
ESBDB
EOS_QRTZ_JOB_DETAILS
ESBDB
EOS_QRTZ_CALENDARS
OWNER
--------------------------------------------------------------------------------
TABLE_NAME
--------------------------------------------------------------------------------
ESBDB
EOS_QRTZ_BLOB_TRIGGERS
ESBDB
DI_PROCESS_MODEL
ESBDB
COMP_WIN7_CONFIG
OWNER
--------------------------------------------------------------------------------
TABLE_NAME
--------------------------------------------------------------------------------
ESBDB
CAP_RULE
118 rows selected.
创立一个dba权限用户用于导出
grant dba to jason identified by jason;
创建逻辑目录
SQL> create or replace directory dp_dir as '/home/oracle';
Directory created.
SQL> exit
授权对逻辑目录的读写权限,如果用户为dba权限可以忽略
SQL> grant read,write on directory dp_dir to dp;
Grant succeeded.
源库添加pdb tns
esb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle12c-70)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = esb)
)
)
测试tns返回0msec表示成功
[oracle@oracle12c-70 admin]$ tnsping esb
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 29-APR-2020 11:19:23
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.2.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle12c-70)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = esb)))
OK (0 msec)
导出操作
[
oracle@oracle12c-70 ~]$ expdp jason/jason@esb directory=dp_dir dumpfile=esbdb.dmp logfile=esbdb.log schemas=esbdb
Export: Release 12.2.0.1.0 - Production on Tue Apr 28 17:04:23 2020
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Starting "JASON"."SYS_EXPORT_SCHEMA_01": jason/********@esb directory=dp_dir dumpfile=esbdb.dmp logfile=esbdb.log schemas=esbdb
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/VIEW/VIEW
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/TRIGGER
. . exported "ESBDB"."REG_CONTENT" 2.221 MB 2412 rows
. . exported "ESBDB"."REG_CONTENT_HISTORY" 139.0 KB 206 rows
. . exported "ESBDB"."REG_RESOURCE" 169.5 KB 1527 rows
. . exported "ESBDB"."REG_PATH" 53.11 KB 410 rows
. . exported "ESBDB"."REG_SNAPSHOT" 15.85 KB 206 rows
. . exported "ESBDB"."SSM_SERVICE_TOP" 3.701 MB 51 rows
. . exported "ESBDB"."REG_RESOURCE_HISTORY" 31.37 KB 206 rows
. . exported "ESBDB"."SAM_OPERATION" 22.53 KB 94 rows
. . exported "ESBDB"."ORG_EMPLOYEE" 22.07 KB 1 rows
. . exported "ESBDB"."APP_MENU" 19.11 KB 57 rows
. . exported "ESBDB"."UM_USER_PERMISSION" 0 KB 0 rows
Master table "JASON"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for JASON.SYS_EXPORT_SCHEMA_01 is:
/home/oracle/esbdb.dmp
Job "JASON"."SYS_EXPORT_SCHEMA_01" successfully completed at Tue Apr 28 17:09:45 2020 elapsed 0 00:05:21
dmp与logfile名称都由自己定
导入操作
前期准备工作跟导出差不多,同样要创建逻辑目录
创立一个dba权限用户用于导出
grant dba to jason identified by jason;
创建逻辑目录
SQL> create or replace directory dp_dir as '/home/oracle';
Directory created.
SQL> exi
t
授权对逻辑目录的读写权限,如果用户为dba权限可以忽略
SQL> grant read,write on directory dp_dir to dp;
Grant succeeded.
源库添加pdb tns
esb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle12c-70)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = esb)
)
)
测试tns返回0msec表示成功
[oracle@oracle12c-70 admin]$ tnsping esb
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 29-APR-2020 11:19:23
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.2.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle12c-70)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = esb)))
OK (0 msec)
imp导入
```bash
[oracle@oracle12c-70 ~]$ impdp jason/jason@esb directory=dp_dir dumpfile=esbdb.dmp logfile=esbdb.log schemas=esbdb
Import: Release 12.2.0.1.0 - Production on Tue Apr 28 17:21:12 2020
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Master table "JASON"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "JASON"."SYS_IMPORT_SCHEMA_01": jason/********@esb directory=dp_dir dumpfile=esbdb.dmp logfile=esbdb.log schemas=esbdb
Processing object type SCHEMA_EXPORT/USER