网站首页 > 技术文章 正文
概述
继上篇expdp导出,这里主要分享怎么去用impdp命令。
1. 首先需要创建Directory
这里目录名字定义为"jy",
若是windows平台,对应系统目录为"E:\jingyu";
create or replace directory jy as 'E:\jingyu';
若是Unix/Linux平台,对应系统目录为"/tmp/jingyu".
create or replace directory jy as '/tmp/jingyu';
注意:目录在系统上需要真实存在(mkdir -p /tmp/jingyu),且有访问的权限。
2. 创建表空间和用户及赋权
create tablespace users datafile '+data1' size 10M autoextend on maxsize 30G; create user scott identified by tiger default tablespace users; grant connect, resource to scott; grant read, write on directory jy to scott;
3. 使用impdp导入用户数据
初始化环境:
初始1:得到删除当前用户下表的SQL:select 'drop table '||table_name||' purge;' from user_tables;
初始2:得到查询当前用户下表的数据量:select 'select count(1) from '||table_name||';' from user_tables;
3.1 导入scott用户的元数据,且不包含统计信息;
impdp system directory=jy dumpfile=scott_meta.dmp logfile=impdp_scott_meta.log
3.2 导入scott用户的数据;
在3.1导入元数据后才可以导入数据。
impdp system directory=jy dumpfile=scott_data.dmp logfile=impdp_scott_data.log
3.3 只导入scott用户下的emp表及数据;
这里为了演示导入,先初始化删除scott用户下的所有表。
impdp scott directory=jy tables=emp dumpfile=scott_emp_dept.dmp logfile=impdp_scott_emp.log
3.4 只导入scott用户下的emp,dept表结构;
这里为了演示导入,先初始化删除scott用户下的所有表。
impdp scott directory=jy tables=emp,dept dumpfile=scott_emp_dept_meta.dmp logfile=impdp_scott_emp_dept_meta.log
由于导出就是emp,dept两张表,所以也可以不指定tables,以下两种写法在这里都是可以的:
impdp scott directory=jy dumpfile=scott_emp_dept_meta.dmp logfile=impdp_scott_emp_dept_meta.log impdp scott directory=jy dumpfile=scott_emp_dept_meta.dmp logfile=impdp_scott_emp_dept_meta.log full=y
3.5 并行导入scott用户下所有的内容;
impdp system directory=jy schemas=scott table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2
这里对于已经存在的对象直接replace掉。
总结
到这里关于expdp和impdp就告一段落啦,在工作中这个还是很实用的,而且会碰到各种奇怪的问题,例如expdp导出时显示乱码、导入时提示用户不存在等等,这种就要靠大家多多尝试了。
后面会分享更多关于DBA内容,感兴趣的朋友可以关注下!!
猜你喜欢
- 2024-10-16 oracle数据库得备份方式 oracle数据库三种备份方式
- 2024-10-16 SmartSQL一款方便快捷的数据库文档查询、导出工具
- 2024-10-16 从零开始学习Oracle之数据备份与还原
- 2024-10-16 Oracle11g中使用expdp导sys用户下的表时报错ORA-39166/ORA-31655
- 2024-10-16 Oracle SQLPlus导出数据到csv文件
- 2024-10-16 Oracle 转换成 MySQL oracle转mysql sql语句
- 2024-10-16 ORACLE 体系 - 14 oracle体系结构思维导图
- 2024-10-16 记一次生产数据库Oracle数据泵导出报ORA-31617错误的解决过程
- 2024-10-16 超级好用的数据库表结构导出工具 数据库导出表结构语句
- 2024-10-16 记Oracle中快速获取表及其各个字段注释的方法
你 发表评论:
欢迎- 最近发表
-
- 前端流行框架Vue3教程:13. 组件传递数据_Props
- 前端必看!10 个 Vue3 救命技巧,解决你 90% 的开发难题?
- JAVA和JavaScript到底是什么关系?是亲戚吗?
- Java和js有什么区别?(java和javascript的区别和联系)
- 东方标准|Web和Java的区别,如何选择这两个专业
- 前端面试题-JS 中如何实现大对象深度对比
- 360前端一面~面试题解析(360前端笔试)
- 加班秃头别慌!1 道 Vue 面试题,快速解锁大厂 offer 通关密码
- 焦虑深夜刷题!5 道高频 React 面试题,吃透 offer 稳了
- 2025Web前端面试题大全(整理版)面试题附答案详解,最全面详细
- 标签列表
-
- 前端设计模式 (75)
- 前端性能优化 (51)
- 前端模板 (66)
- 前端跨域 (52)
- 前端md5加密 (49)
- 前端路由 (55)
- 前端数组 (65)
- 前端定时器 (47)
- 前端懒加载 (45)
- 前端接口 (46)
- Oracle RAC (73)
- oracle恢复 (76)
- oracle 删除表 (48)
- oracle 用户名 (74)
- oracle 工具 (55)
- oracle 内存 (50)
- oracle 导出表 (57)
- oracle查询数据库 (45)
- oracle约束 (46)
- oracle 中文 (51)
- oracle链接 (47)
- oracle的函数 (57)
- mac oracle (47)
- 前端调试 (52)
- 前端登录页面 (48)
本文暂时没有评论,来添加一个吧(●'◡'●)