09 Oracle数据汞(expdp)导入导出

  • 管理员用户下:system建立目录对象
create directory MY_DIR 'c:\dir1'

--授权给scott用户读写
grant read,write on directory MY_DIR to scott;
  • 导出(入)scott用户的student address表
expdp scott/scott@orcl directory=MY_DIR dumpfile=expdp_scott1.dmp
tables=(student,address)

--导入student,address
impdb scott/scott@orcl directory=MY_DIR dumpfile=expdp_scott1.dmp
  • 导出scott的student address表的表结构,不导出数据 reuse_dumpfiles=y(覆盖之前的 N不覆盖)
expdp scott/scott@orcl directory=MY_DIR dumpfile=expdp_scott1.dmp
tables=(student,address) content=metadata_only reuse_dumpfiles=y
  • 导出scott的student address表的数据,不导出结构
expdp scott/scott@orcl directory=MY_DIR dumpfile=expdp_scott1.dmp
tables=(student,address) content=data_only reuse-dumpfiles=y
  • 导出scott、hr用户的内容
expdp system/system@orcl directory=MY_DIR dumpfile=expdp_scott1.dmp
schemas=(scott,hr) job_name=expdp1
  •  导出student表和其上的约束索引
--传统导出
exp scott/scott@orcl tables=student file=c:\exp11.dmp
--然后导入
imp scott/scott@orcl file=c:\exp11.dmp

expdp scott/scott@orcl directory=MY_DIR dumpfile=expdp_scott3.dmp tables=student
  • 导出student表的约束,不导出索引
--传统的导出
exp scott/scott@orcl tables=student file=c:\exp11.dmp indexes=n

expdp scott/scott@orcl directory=MY_DIR dumpfile=expdp_scott4.dmp tables=student
exclude=index --排除索引
  • 导出student表,不导出索引,不导出约束
--传统
exp scott/scott@orcl tables=student file=c:\exp11.dmp indexes=n constraints=n

expdp scott/scott@orcl directory=MY_DIR dumpfile=expdp_scott4.dmp tables=student
exclude=index,constraint --排除索引约束
  • 对于scott对象,不导出student address表,但导出其他表
expdp scott/scott@orcl tables=student file=c:\exp11.dmp
exclude=table:"in('STUDENT')" exclude=table:"in('ADDRESS')"
  •  导出student表约束,索引;导出address表的结构和数据,不导出约束索引
expdp scott/scott@orcl directory=MY_DIR dumpfile=expdp6.dmp tables=(student,address)
exclude=constraint:"in('CON_ZZ')" exclude=index:"in('IND_ADD_SNO')"
  •  导出student表约束,索引;导出address表的结构和数据,不导出约束索引(参数文件)
expdp scott/scott@orcl parfile='c:\exp1.txt'
exp1.txt文件内容:
directory=MY_DIR dumpfile=expdp7.dmp
include=table:"in('STUDENT','ADDRESS')"
include=index:"in('PK_SNO','IND_STU_SNAME')"--包含
include=constraint:"in('PK_SNO','CON_SAGE')"--包含
  • 导出student表记录sno>1的记录,导出address表sno=2的记录
expdp scott/scott@orcl parfile='c:\exp2.txt'
exp2.txt文件内容:
directory=MY_DIR dumpfile=expdp8.dmp
reuse_dumpfiles=y--覆盖之前的,
tables=student,address
query=student:"where sno>1",address:"where sno=2"--query子集
  • remap_schema的使用:用于将对象从一个用户下导入到另一个用户下
expdp scott/scott@orcl directory=MY_DIR dumpfile=expdp1.dmp schemas=scott
grant read,write on directory MY_DIR on hr 
hr进行导入
impdp hr/hr@orcl directory=MY_DIR dumpfile=expdp1.dmp tables=student
remap_schema=scott:hr
  • remap_tablespace:用于将对象从一个表空间下导入到另外一个表空间下
expdp scott/scott@orcl directory=MY_DIR dumpfile=expdp1.dmp schemas=scott
impdp hr/hr@orcl directory=MY_DIR dumpfile=expdp1.dmp remap_tablespace=users:example

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值