直接上案例:
while read line do table_name=`echo $line | awk '{print $1}'` echo $table_name echo "Start running SQL script for DB "$table_name" at "$(date +%Y-%m-%d%t%A%t%T) >> $logfile mysql -pbfgame20 <<EOF use log_db; alter table log_db.$table_name drop partition p$PARTNAME4,p99; alter table log_db.$table_name add partition(partition p$NOWNAME VALUES LESS THAN (to_days('$NOW_MONTHS')) ENGINE = InnoDB); alter table log_db.$table_name add partition(partition p99 VALUES LESS THAN MAXVALUE ENGINE = InnoDB); EOF done<$FILE1