切换oracle用户impdp,Oracle 12c pdb使用expdp/impdp导入导出
12c推出了可插拔数据库,在一个容器cdb中以多租户的形式同时存在多个数据库pdb。在为pdb做数据泵导入导出时和传统的数据库有少许不同。
1,需要为pdb添加tansnames
2,导入导出时需要在userid参数内指定其tansnames的值,比如 userid=user/pwd@tnsname
数据泵导出
1、查看当前的SID,查看pdb并切换到容器数据库,这里的pluggable数据库是pdborcl[oracle@test admin]$ echo $ORACLE_SID
[oracle@test admin]orcl
登录cdb,查看pdb,SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
PDB$SEED READ ONLY NO
PDBORCL MOUNTED
SQL> alter pluggable database all open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
PDB$SEED READ ONLY NO
PDBORCL READ WRITE NO
切换到pdborclSQL> alter session set container=pdborcl;
Session altered.
SQL>
2、查看示例用户scott,以后的schema级别导入导出就使用该用户的数据。SQL> select owner, table_name from dba_tables where owner='SCOTT';
OWNER TABLE_NAME
------------------------------ ----------------------------------------
SCOTT SALGRADE
SCOTT BONUS
SCOTT EMP
SCOTT DEPT
3、单独创建一个dba权限的数据泵用户SQL> grant dba to dp identified by dp;
Grant succeeded.
4、创建一个数据泵目录dp_dir,路径为oracle家目录SQL> create or replace directory dp_dir as '/home/oracle';
Directory created.
SQL> exit
5、授予dp用户在数据泵路径有读写权限
(如果是dba权限的这一步可以省略,为了试验的完整性这里保留)SQL> grant read,write on directory dp_dir to dp;
Grant succeeded.
6、设置tnsnames.ora,增加pdborocl。SERVICE_NAME为pdb的实例名,这里为pdborcl[oracle@xqzt admin]$ pwd
/data/app/oracle/product/12.1.0/dbhome_1/network/admin
[oracle@xqzt admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /data/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xqzt)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
PDBORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xqzt)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME =pdborcl)
)
)
7、测试tnsnames.ora的有效性,如果返回OK (0 msec)表示配置成功[oracle@xqzt admin]$ tnsping pdborcl
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 10-DEC-2015 09:10:34
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
/data/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = xqzt)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =pdborcl)))
OK (0 msec)
8、数据泵导出用户名密码为dp/dp,并且通过tnsnames指向pdborcl
数据泵目录为:dp_dir, OS路径是/home/oracle
导出文件为:/home/oracle/scott_pdborcl.dmp
导出日志为:/home/oracle/scott_pdborcl.log
导出模式为scheme,也可以理解为用户:scott[oracle@xqzt ~]$ expdp dp/dp@pdborcl directory=dp_dir dumpfile=scott_pdborcl.dmp logfile=scott_pdborcl.log schemas=scott
Export: Release 12.1.0.2.0 - Production on Thu Dec 10 09:32:05 2015Copyright (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, OLAP, Advanced Analytics and Real Application Testing options
Starting "DP"."SYS_EXPORT_SCHEMA_01": dp/********@pdborcl directory=dp_dir dumpfile=scott_pdborcl.dmp logfile=scott_pdborcl.log schemas=scott
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 192 KB
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/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
. . exported "SCOTT"."DEPT" 6.023 KB 4 rows
. . exported "SCOTT"."EMP" 8.773 KB 14 rows
. . exported "SCOTT"."SALGRADE" 6.023 KB 10 rows
. . exported "SCOTT"."BONUS" 0 KB 0 rows
Master table "DP"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for DP.SYS_EXPORT_SCHEMA_01 is:
/home/oracle/scott_pdborcl.dmp
Job "DP"."SYS_EXPORT_SCHEMA_01" successfully completed at Thu Dec 10 09:32:29 2015 elapsed 0 00:00:21
[oracle@xqzt ~]$
10、查看导出文件[oracle@xqzt ~]$ ls -l scott_pdborcl.dmp scott_pdborcl.log
-rw-r----- 1 oracle oinstall 356352 12月 10 09:32 scott_pdborcl.dmp
-rw-r--r-- 1 oracle oinstall 1960 12月 10 09:32 scott_pdborcl.log
11、为了测试导出文件是否能够正常导入,我们先删除pdborcl的scott用户SQL> select count(*) from scott.DEPT;
COUNT(*)
----------
SQL> drop user scott cascade ;
User dropped.
SQL>
此时访问该用户的表已经不存在了SQL> select count(*) from scott.DEPT;
select count(*) from scott.DEPT
*ERROR at line 1:
ORA-00942: table or view does not exist
12、 导入scott用户[oracle@xqzt ~]$ impdp dp/dp@pdborcl directory=dp_dir dumpfile=scott_pdborcl.dmp logfile=scott_pdborcl_imp.log schemas=scott
Import: Release 12.1.0.2.0 - Production on Thu Dec 10 09:39:02 2015Copyright (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, OLAP, Advanced Analytics and Real Application Testing options
Master table "DP"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "DP"."SYS_IMPORT_SCHEMA_01": dp/********@pdborcl directory=dp_dir dumpfile=scott_pdborcl.dmp logfile=scott_pdborcl_imp.log schemas=scott
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/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."DEPT" 6.023 KB 4 rows
. . imported "SCOTT"."EMP" 8.773 KB 14 rows
. . imported "SCOTT"."SALGRADE" 6.023 KB 10 rows
. . imported "SCOTT"."BONUS" 0 KB 0 rows
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "DP"."SYS_IMPORT_SCHEMA_01" successfully completed at Thu Dec 10 09:39:06 2015 elapsed 0 00:00:04
[oracle@xqzt ~]$
13、 测试导入结果SQL> select count(*) from scott.DEPT;
COUNT(*)
----------
4
导入成功!
切换oracle用户impdp,Oracle 12c pdb使用expdp/impdp导入导出相关推荐
- oracle12c导入,Oracle 12c pdb使用expdp/impdp导入导出
1.查看当前的SID,查看pdb并切换到容器数据库,这里的pluggable数据库是pdborcl[oracle@test admin]$ echo $ORACLE_SID [oracle@test ...
- grid赋予oracle磁盘权限,grid 与 Oracle 用户下 Oracle 程序权限不一致导致无法连接 ASM 问题...
grid 与 Oracle 用户下 Oracle 程序权限不一致导致无法连接 ASM 问题 在 RAC 中, 启动数据库时遇到如下报错:Oracleinstance started. TotalSys ...
- oracle备份密码文件,[数据库]Oracle数据库备份dmp文件,使用cmd命令导入导出步骤,以及忘记Oracle密码_星空网...
Oracle数据库备份dmp文件,使用cmd命令导入导出步骤,以及忘记Oracle密码 2013-07-30 0 dmp文件导入导出步骤 1.创建表空间 --datafile 的路径随便给,但是后面的 ...
- mysql 导入pdb_12c pdb的数据泵导入导出简单示例
12c推出了可插拔数据库,在一个容器cdb中以多租户的形式同时存在多个数据库pdb.在为pdb做数据泵导入导出时和传统的数据库有少许不同. 1,需要为pdb添加tansnames 2,导入导出时需要在 ...
- Oracle 数据泵(IMPDP/EXPDP)导入导出总结
Oracle数据泵导入导出是日常工作中常用的基本技术之一,它相对传统的逻辑导入导出要高效,这种特性更适合数据库对象数量巨大的情形,因为我日常运维的数据库对象少则几千,多则几万甚至几十万,所以传统exp ...
- 给oracle用户赋权限导入导出,Oracle常用命令-用户、表空间、赋权限、导入导出...
1.1 删除表空间 drop tablespace QBKJ including contents and datafiles; 1.2 删除用户 drop user admin cascad ...
- Oracle 20c 新特性:数据泵 expdp / impdp 的EXCLUDE和CHECKSUM增强
墨墨导读:随着 Oracle 的数据泵技术不断增强,这个逻辑数据备份和迁移工具,已经成为了 Oracle 数据库用户的首选工具之一,在 20c 中, expdp / impdp 都获得了大量的特性增强 ...
- oracle 用户无限期,oracle永久密码和登录次数无限制设置
http://www.cnblogs.com/tippoint/archive/2013/03/08/2950126.htmlhtml 修改oracle用户密码永不过时:linux 一.查看用户的pr ...
- sql developer Oracle 数据库 用户对象下表及表结构的导入导出
Oracle数据库表数据及结构的导入导出 导出的主机与即将导入到的目标主机的tablespace 及用户名需一直!!!!!
最新文章
- 访问系统相册或调用摄像头
- 【2019/4/30】周进度报告
- Java帝国对Python的渗透能成功吗?
- 谷歌全方位自曝Waymo无人车技术方案 | 42页报告要点解读+下载
- Windows核心编程 第九章 线程与内核对象的同步(上)
- 听说这是和女朋友住一起后的现象之一
- pythonxlwt行居中_python3-xlwt-Excel设置(字体大小、颜色、对齐方式、换行、合并单元格、边框、背景、下划线、斜体、加粗)...
- python中表示空类型的是_python中怎么表示空值
- 腾讯优图提出LCVR-MQVI算法,勇夺NTIRE 2021双赛道冠亚军
- Bootstrap 导航
- AEAI DP开发统计分析
- matlab绘制奈奎斯特图
- MD5加密——使用Java自带的MessageDigest工具类实现
- 使用Word(Office 365)版本中的简历助手
- java 热度算法_Raddit算法Java实现
- 【破解软件】知音漫客免费看更多漫画
- 清理浏览器html缓存图片吗,在JSP或Javascript中清除浏览器缓存中的图像
- [构造]triples I
- 倾斜摄影数据转cesium 3dtile(详细步骤)
- spacemacs email layer