#!/bin/bashsql
#######bash
腳本名稱:addpar.shless
建立時間:spa
描述:code
########it
if [ $# lt 4 ]io
thentable
echo 「usage:$0 <par_table> <tablespace><daterang_yyyymm><flag>」date
exit 1select
fi
date_less=‘sqlplus -s use/pawd@db <<EOF
whenever sqlerror exit sql.sqlcode
set verify off
set echo off
set feedback off
set heading off
set term off
set linesize 255
set pagesize 0
select to_char(add_months(to_date(‘$3’,’yyyymm’),1),’yyyymmdd’) from dual;
exit
EOF
’
date_less_mon=‘sqlplus -s use/pawd@db <<EOF
whenever sqlerror exit sql.sqlcode
set verify off
set echo off
set feedback off
set heading off
set term off
set linesize 255
set pagesize 0
select to_char(add_months(to_date(‘$3’,’yyyymm’),1),’yyyymm’) from dual;
exit
EOF
’
if [ 「$4」 == 「1」 ];then
sqlplus usr/passwd@db<<EOF
alter table $1 add partition p$3 values less than (‘$date_less’) tablespace $2 initrans 2 maxtrans 255;
EOF
else
sqlplus usr/passwd@db<<EOF
alter table $1 add partition p$3 values less than (‘$date_less_mon’) tablespace $2 initrans 2 maxtrans 255;
EOF
fi