暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

oracle expdp/impdp数据泵操作

在路上 2024-11-29
93

1.创建表空间

create tablespace xx datafile '' size 5g autoextend on next 1g maxsize unlimited;

2.创建用户并授权

create user ams_test identified by xx
default tablespace ams_test
temporary tablespace temp
quota unlimited on ams_test;
grant connect ,resource to ams_test;

2.创建备份目录并授权

create or replace directory expdp_dir as '/home/oracle/expdp_dir';
grant read,write on directory expdp_dir to myuser;

3.导出某个用户

expdp myuser/mypassword directory=expdp_dir dumpfile=20240919.dmp logfile=20240919.log schemas=myuser

4.导入

impdp myuser/mypassword directory=expdp_dir dumpfile=20240919.dmp logfile=20240919.log remap_schema=ams:ams_test remap_tablespace=ams:ams_test table_exists_action=append
table_exists_action参数:
    skip:表已存在,则跳过该表的导入
    append:如果表已存在,则将新数据追加到现有表中,不会覆盖原有数据
    truncate:如果表已存在,则先截断表,然后导入新数据。
    replace:如果表已存在,则删除现有表并重建它

5.写入脚本定时

BACKUPTIME=$(date +%Y%m%d%H%M%S) ORACLE_SID=bom DMPNAME=bom_$BACKUPTIME.dmp LOGNAME=bom_$BACKUPTIME.log expdp system/oracle directory=DMPDIR1 dumpfile=$DMPNAME logfile=$LOGNAME full=y 加入定时任务crontab -e30 22 * * * su - oracle -c /tmp/expdp.sh 

30 23 * * * find /tmp/dbbackup -ctime +1 |xargs rm 2>&1 > /dev/null





「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论