mysql> alter table trends truncate partition p20150810;
Query OK, 0 rows affected (0.37 sec)
mysql> select count(*) from trends partition(p20150810);
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.31 sec)
oadb01:/home/oracle/mysql> cat t1.sh
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
date=`echo $1 | tr -d '-'`
date1=`echo $2 | tr -d '-'`
date2=`echo $1`
date_end=`get_date $2 +1 | tr -d '-'`
while :
do
date3=`get_date $date +1`
var=`date -d "$date3" +%s`
echo "alter table trends truncate partition p$date;"
date2=`get_date $date +1`
date=`echo $date2 | tr -d '-'`
#echo $date3
if [ "$date" = "$date_end" ]
then
exit
fi
done