码迷,mamicode.com
首页 > 其他好文 > 详细

EXP自适应导出指定表脚本

时间:2014-08-24 17:50:22      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:des   使用   io   文件   ar   art   问题   cti   log   

############crontab设置###########

30 1 * * * /home/oracle/backup/backupsh/expfull.sh

 

 

############expfull.sh设置###########

/home/oracle/backup/backupsh/tables.sh

cat /home/oracle/backup/backupsh/exp_temp.parfile > /home/oracle/backup/backupsh/expfull.parfile

cat /home/oracle/backup/backupsh/tables.lst >> /home/oracle/backup/backupsh/expfull.parfile

/home/oracle/backup/backupsh/start_exp.sh

 

 

############start_exp.sh设置###########

source /home/oracle/.bash_profile

BACK_HOME=/home/oracle/backup

BACK_DEST=$BACK_HOME/expfull

SH_HOME=/home/oracle/backup/backupsh

export $BACK_HOME

export $BACK_DEST

export $SH_HOME

DBA="599128198@qq.com"

DATE=`date +"%m%d:%H.%M"`

IP=""

exp_log_file=$SH_HOME/expfull.log

MAIL_COMMAND=/bin/mailx

$ORACLE_HOME/bin/exp parfile=$SH_HOME/expfull.parfile;

cat $exp_log_file |$MAIL_COMMAND -s "exp backup message from $IP $DATE " $DBA

 

###########exp_temp.parfile##############

userid=xzsp/xzsp

filesize=2048M

file=(/home/oracle/backup/fulldmp1.dmp,

/home/oracle/backup/fulldmp2.dmp,

/home/oracle/backup/fulldmp3.dmp,

/home/oracle/backup/fulldmp4.dmp)

rows=y

log=/home/oracle/backup/backupsh/expfull.log

compress=n

buffer=40960000

direct=y

 

##############tables.sh###################

sqlplus -S "/ as sysdba" >/dev/null <<EOF

set echo off

set termout off

set feedback off

set heading off

set linesize 120

set pagesize 0

 

select to_char(sysdate,‘‘‘yyyy-mm-dd hh:mm:ss‘‘‘) from dual;

spool /home/oracle/backup/backupsh/tables.lst

SELECT ‘tables=(‘ || CHR(10) FROM DUAL;

SELECT owner || ‘.‘ || table_name || ‘,‘ || CHR(10)

FROM dba_tables

WHERE owner NOT IN (‘SYS‘,‘SYSTEM‘,‘CTXSYS‘,‘ORDSYS‘,‘MDSYS‘)

    AND table_name NOT IN

     (‘SMS_LOG‘,‘SMS_RESPREPT_ERROR‘,‘SMS_STATUSREPT‘,‘PUSH_USER_INFO_LOG‘)

ORDER BY owner;

SELECT ‘SYS.DUAL‘ FROM DUAL;

SELECT ‘)‘ FROM DUAL;

spool off

EOF

 

说明:ORACLE10G 以后解决这个问题更方便,使用exclude include。用法如下:

EXCLUDE = object_type[:name_clause][,…]

INCLUDE = object_type[:name_clause][,…]

例如:

Expdp <other_paramters> SCHEMAS=XZSP EXCLUDE=SEQUENCE,INDEX,TABLE:”LIKE %EMP”

IMpdp <other_paramters> SCHEMAS=XZSP INCLUDE=FUNCTION,PACKAGE,PROCEDUGE ,TABLE:”IN (‘EMP’,’DEMP’)”

Linux下使用需要使用转义字符“\”,当然最好使用参数文件

############定义参数文件parfile.par ##############

Directory=expdir

Schemas=rman

Dumpfile=expdp_rman.dmp

Include=TABLE:”IN(‘DB’,’TS’)”

执行导出命令如下

Expdp \’/ as sysdba \’ parfile.par

EXP自适应导出指定表脚本

标签:des   使用   io   文件   ar   art   问题   cti   log   

原文地址:http://www.cnblogs.com/markfeifei/p/3932931.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!