拓扑园

  • O&M
    • Universal部署
    • PHP+VUE+Laravel相关
  • Oracle性能优化
  • Oracle项目案例
    • Oracle近期项目案例(目录)
    • Oracle实战问题解析(目录)
    • Oracle数据库名变更流程(2种方式)
    • Oracle数据库目录更换流程(使用Oracle的clone工具)
    • Oracle数据库迁移方案(目录)
    • 标准化文档系列
  • Oracle基础知识
    • LLL的Oracle培训(分类)
    • LLL的docker培训(分类)
    • 标准化文档系列--(分类)
    • Oracle核心经典分析(分类)
    • 图灵小队----(分类并包含以下文章)
    • --MySQL8.0/Oracle/Memcached/Redis等安装配置于RHEL/OL6/7/8.X系列-运行环境最优配置
    • --PG安装配置于RHEL/9X系列-运行环境最优配置
    • --自动维护任务详解-开启、关闭信息统计收集(统计信息)
    • --图灵小队—Oracle/PostgreSQL下创建一个用户测试表(自行定义数据行)
    • --图灵小队-Oracle存储过程导出表的明细_UTL_FILE(文章)
    • --图灵小队-Oracle数据库删除/卸载操作指南(文章)
    • --图灵小队-Oracle常用性能查询SQL语句(文章)
    • --图灵小队-Oracle数据库上线前检查(文章)
    • --图灵小队-Oracle常用SQL语句(文章)
    • --图灵小队—Linux/Oracle脚本/MySQL合集(持续更新)
    • --图灵小队-Oracle技巧记录(文章)
    • ADG
    • RAC
    • ASM
    • OGG
    • RMAN
    • EXPDP/IMPDP
    • 工厂数据导入导出系列
  • MySQL
    • MySQL数据库规范
    • MySQL项目案例
    • MySQL安装配置
    • MYSQL集群项目
    • MySQL常见处理
    • MySQL-Sysbench专题
    • MySQL-Percona Toolkit专题
  • Linux
    • Shell编程
    • kubernetes
    • docker
    • Linux
    • PHP
    • Nginx
    • haproxy
    • mail
    • 网站
    • 域名
    • 网址收藏
  • 数据中心
    • 新框架系统集合
    • 工作文档
    • EBS数据文件扩容
    • VMware虚拟化
    • EBS系列
    • 大数据
    • SVN
    • zabbix
    • SAP
    • 备份相关
    • FC交换机
    • SVN
  • K-Studing
    • D8-Python学习
    • Oracle/MySQl等面试题
    • LG-MySQL
    • LG-Docker/K8S
    • LG-PostgreSQL
    • LG-ORACLE_BBED
    • LG-ORACLE
    • LG-Elasticsearch(ES)+ELK
    • Oracle-19C-OCP
    • WERN_ORACLE培训
    • redis数据库
    • Nginx培训学习系列
  • 其他
    • 外研英语4年级下册-听力
    • 影视系列
    • 如何使用iTunes软件通过抓包下载旧版本的ios的app
天高任鸟飞
Oracle/MySQL数据库恢复/数据迁移/生产规范报告技术交流:TEL:18562510581(微信同号);加微信入群
  1. 首页
  2. Oracle基础知识
  3. LLL的Oracle培训
  4. 正文

LLL的数据库培训-18-第二部分—Oracle基础知识培训—第10讲—Oracle11g的逻辑备份—impdp与expdp案例实操

2021年7月16日 1173点热度 0人点赞 0条评论

目录

  • 一、expdp的重要参数
    • 1、directory:
    • 2、job_name:
    • 3、content:
    • 4、reuse_dumpfiles:
    • 5、compression:
    • 6、estimate:
    • 7、 estimate_only:
    • 8、exclude:
    • 9、include:
    • 10、query:
    • 11、attch:
  • 二、导出举例
    • 1、建立转储(存放)目录
    • 2、目录对象[system权限]:
    • 3、导出scott的student,address表
    • 4、导出scott用户student、address的表结构,不导出数据
    • 5、导出scott用户【用system导出普通用户】
    • 6、只导出scott用户student、address的表数据,不导出结构
    • 7、导出student表、和表上面的主约束、索引
    • 8、【exclude】导出student表、约束,但不导出索引
    • 9、【exclude】导出student表,不导出约束、不导出索引
    • 10、【exclude】导出scott对象的表,但不导出student,BONUS表
    • 11、【exclude】导出student表和约束、索引,导出addres表的结构和数据,但不导出address表的约束和索引
    • 12、【include】导出student表和约束、索引,导出addres表的结构和数据,但不导出address表的约束和索引
    • 13、【include】导出student表的sno>1的记录,和address的sno=2的记录
    • 14、估算导出占用的磁盘空间
  • 三、impdp的重要参数
    • 1、content:
    • 2、estimate:
    • 3、remap_schema:
    • 4、remap_tablespace:
    • 5、remap_datafile:
  • 四、impdp的举例
    • 1、remap_schames的使用
    • 2、remap_tablespaces的使用

LLL的数据库培训—第二部分—Oracle培训—第10讲—Oracle11g的逻辑备份—impdp与expdp案例实操

一、expdp的重要参数

部分的exp中的参数仍然可用,有的不能使用,如index。

1、directory:

供转储文件和日志文件使用的目录对象。

2、job_name:

指定的任务的名称。

3、content:

指定要导出的数据, 其中有效关键字值为: (ALL), DATA_ONLY 和 METADATA_ONLY,当设置content为ALL 时,将导出对象定义及其所有数据;

DATA_ONLY时,只导出对象数据;为METADATA_ONLY时,只导出对象定义 。

4、reuse_dumpfiles:

如果导出文件已经存在,是否覆盖。

5、compression:

压缩导出文件。

6、estimate:

指定估算被导出表所占用磁盘空间分方法,默认值是BLOCKS

7、 estimate_only:

是否只估算导出占用的磁盘空间,而不进行真正的导出,默认是N。

8、exclude:

用于指定执行操作时要排除对象类型或相关对象,用法:

EXCLUDE=object_type[:name_clause] [,….]

9、include:

用于指定执行操作时要包含的对象类型或相关对象,用法:

INCLUDE=object_type[:name_clause] [,….]

10、query:

导出符合条件的行。

11、attch:

连接到现有的作业,可以用在中断导出任务后重新启动导出任务。

二、导出举例

1、建立转储(存放)目录

[oracle@localhost ~]$ mkdir /data/expdpbackup/

2、目录对象[system权限]:

SQL>create directory mes_backup as '/data/expdpbackup';
SQL>grant read,write on directory  mes_backup to scott;

3、导出scott的student,address表

expdp scott/scott directory=mes_backup dumpfile=expdp_scott1.dmp tables=student,address

导出过程,会出现sys_export_table_01表,通过select * from tab可以查到,即前面说的MT表

1587562974421485.png

4、导出scott用户student、address的表结构,不导出数据

reuse_dumpfiles=y 覆盖已存在的dmp文件,默认为n,不覆盖
expdp scott/scott directory=mes_backup dumpfile=expdp_scott2.dmp tables=student,address content=metadata_only reuse_dumpfiles=y

导入 expdp_scott2.dmp,查看是否只有结构而没有数据。

impdp scott/scott directory=mes_backup dumpfile=expdp_scott2.dmp

image.png

image.png

5、导出scott用户【用system导出普通用户】

expdp syetem/oracle directory=mes_backup dumpfile=expdp_scott11.dmp s=scott job_name=expdpjob

其中,job_name就是我们指定的MT表的名字

image.png

image.png

6、只导出scott用户student、address的表数据,不导出结构

expdp scott/scott directory=mes_backup dumpfile=expdp_scott2.dmp tables=student,address content=data_only reuse_dumpfiles=y

如果不导出结构,把scott的student和address表删了,再导入的时候,会报错,如下:

impdp scott/scott directory=mes_backup dumpfile=expdp_scott_data-nomata.dmp

image.png

但是如果是空的表,是可以导入的

创建空表,再导入:

create table student(sno int,sname varchar2(10),sage int,constraint pk_sno primary key(sno));
create table address(sno int,zz varchar2(10));
image.png

7、导出student表、和表上面的主约束、索引

exp和expdp都可以实现

exp scott/scott file=/data/exp1.dmp tables=student
expdp scott/scott directory=mes_backup dupfile=expdp_scott3.dmp tables=student

8、【exclude】导出student表、约束,但不导出索引

exp scott/scott file=/data/exp1.dmp tables=student indexes=n
expdp scott/scott directory=mes_backup dupfile=expdp_scott14.dmp tables=student exclude=index

image.png

9、【exclude】导出student表,不导出约束、不导出索引

exp scott/scott file=/data/exp1.dmp tables=student indexes=n constraints=n expdp scott/scott directory=mes_backup dumpfile=expdp_scott15.dmp tables=student exclude=index,constraint

10、【exclude】导出scott对象的表,但不导出student,BONUS表

expdp scott/scott directory=mes_backup dumpfile=expdp_scot17.dmp exclude=table:"in('BONUS')" exclude=table:"in('STUDENT')" 
expdp scott/scott directory=mes_backup dumpfile=expdp_scot17.dmp exclude=table:"in('BONUS','STUDENT')" #这种在参数文件中可以实现,直接运行是不可以的,需要用上述语句

11、【exclude】导出student表和约束、索引,导出addres表的结构和数据,但不导出address表的约束和索引

expdp scott/scott directory=mes_backup dumpfile=expdp_scot18.dmp tables=student,address exclude=constraint:"in('CON_ZZ')" exclude=index:"in('IND_ADD_SNO')"

12、【include】导出student表和约束、索引,导出addres表的结构和数据,但不导出address表的约束和索引

使用参数的方式,expdp1.txt

directory=mes_backup dumpfile=epdp7.dmp include=table:"in('STUDENT','ADDRESS')"  include=index:"in('PK_SNO','IND_STU_SNAME')"  include=constraint:"in('PK_SNO','CON_SAGE')"

执行参数

[oracle@localhost data]$ expdp scott/scott parfile=/data/expdp1.txt

image.png

13、【include】导出student表的sno>1的记录,和address的sno=2的记录

使用参数的方式,expdp2.txt

directory=mes_backup dumpfile=epdp7.dmp reuse_dumpfiles=y tables=student,address query=student:"where sno >1",address:"where sno=2"

执行参数文件

[oracle@localhost data]$ expdp scott/scott parfile=/data/expdp2.txt

image.png

14、估算导出占用的磁盘空间

expdp MESSHYCBZ/Mes1qaz#EDC DIRECTORY=backup_mes estimate_only=y

三、impdp的重要参数

1、content:

指定要加载的数据, 其中有效关键字值为: (ALL), DATA_ONLY 和 METADATA_ONLY,

当设置content为ALL 时,将加载对象定义及其所有数据;

DATA_ONLY时,只加载对象数据;为METADATA_ONLY时,只加载对象定义 。

2、estimate:

估算所占用磁盘空间分方法.默认值是BLOCKS

3、remap_schema:

用于将对象从一个用户下导入到另一个用户下。

4、remap_tablespace:

用于将对象从一个表空间下导入到另一个表空间下。

5、remap_datafile:

用于在不同文件系统的平台间,切换数据文件路径。

四、impdp的举例

1、remap_schames的使用

expdp scott/scott directory=mes_backup dumpfile=expdp1.dmp schemas=scott;

hr进行导入:

impdp test/test directory=mes_backup dumpfile=expdp1.dmp remap_schame=scott:test

2、remap_tablespaces的使用

expdp scott/scott directory=mes_backup dumpfile=expdp1.dmp schemas=scott;

hr进行导入:

impdp test/test directory=mes_backup dumpfile=expdp1.dmp remap_tablespace=users:example
本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2022年8月26日

admin

这个人很懒,什么都没留下

打赏 点赞
< 上一篇
下一篇 >

COPYRIGHT © 2022 拓扑园. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

鲁ICP备2021020523号

鲁ICP备2021020523号