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

针对分区表一个月3个分区定期清理脚本

时间:2018-04-26 13:23:32      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:echo   dba   log   一个   off   SQ   run   lines   .sql   

1.定时任务--当前月的前一个月的当前日期

05 20 1  * *  /bin/sh  /home/oracle/truncate_partition.sh &> /dev/null
05 20 11 * *  /bin/sh  /home/oracle/truncate_partition.sh &> /dev/null
05 20 21 * *  /bin/sh  /home/oracle/truncate_partition.sh &> /dev/null

[oracle@testglt]$ cat /home/oracle/truncate_partition.sh
#!/bin/bash

source /home/oracle/.bash_profile
sqlplus -s test/test@db>> /home/oracle//truncate_partition.log <<EOF
set feedback off heading off term off
set pages 1000 trim on trims on lines 32767 long 999999
set echo off
spool /home/oracle/truncate_partition_`date +%y%m%d`.sql
@/home/oracle//truncate_partition.sql
spool off
EOF

sqlplus sys/test@dbas sysdba  >> /home/oracle/exec_truncate_p.log <<EOF
@/home/oracle/truncate_partition_`date +%y%m%d`.sql
EOF

 

针对分区表一个月3个分区定期清理脚本

标签:echo   dba   log   一个   off   SQ   run   lines   .sql   

原文地址:https://www.cnblogs.com/ss-33/p/8951627.html

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