日期:2014-05-16  浏览次数:20589 次

如何写脚本来定时创建表?

想根据现有表结构在本月创建下个月的表,该怎么写呢?
写了个脚本,遇到点问题,脚本如下:
-----------------------------------------------------------------------------
#!/bin/bash
# the script is used to create table per month.
.  /home/.profile
DBNAME=oracle_home
DBUSER=hao
DBPASSWD=hao123
month=`date +%Y%m`

$ORACLE_HOME/bin/sqlplus -s  ${DBUSER}/${DBPASSWD}@${DBNAME}
create table   hao.product_${month}  as
select * from hao.product_201310
where 0=1;
-----------------------------------------------------------------------------
现在echo "month"为201311,即本月。
month想获取下个月该怎么写?即在11月,获取month=201312.
谢谢

------解决方案--------------------
date --date='next month' +%Y%m