#!/bin/sh
desc="删除分区为:"
#hive数据库名
hiveDbName=gree_monitorcenter_biz1
#hive数据库中的表名
hiveTableName=wp04_0013_data
echo " ------------------开始删除分区数据-----------------------------"
COUNTYEAR=2016
while [ $COUNTYEAR -le 2016 ];do
COUNTMONTH=9
while [ $COUNTMONTH -le 9 ];do
COUNTDAY=1
while [ $COUNTDAY -le 31 ];do
echo " ++++${desc}$COUNTYEAR-$COUNTMONTH-$COUNTDAY++++"
hive -e "use $hiveDbName; \
alter table ${hiveTableName} drop if exists partition(year=$COUNTYEAR,month=$COUNTMONTH,day=$COUNTDAY);"
COUNTDAY=`expr $COUNTDAY + 1`
done
COUNTMONTH=`expr $COUNTMONTH + 1`
done
COUNTYEAR=`expr $COUNTYEAR + 1`
done
echo "------------------------------循环完成-----------------------------"
desc="删除分区为:"
#hive数据库名
hiveDbName=gree_monitorcenter_biz1
#hive数据库中的表名
hiveTableName=wp04_0013_data
echo " ------------------开始删除分区数据-----------------------------"
COUNTYEAR=2016
while [ $COUNTYEAR -le 2016 ];do
COUNTMONTH=9
while [ $COUNTMONTH -le 9 ];do
COUNTDAY=1
while [ $COUNTDAY -le 31 ];do
echo " ++++${desc}$COUNTYEAR-$COUNTMONTH-$COUNTDAY++++"
hive -e "use $hiveDbName; \
alter table ${hiveTableName} drop if exists partition(year=$COUNTYEAR,month=$COUNTMONTH,day=$COUNTDAY);"
COUNTDAY=`expr $COUNTDAY + 1`
done
COUNTMONTH=`expr $COUNTMONTH + 1`
done
COUNTYEAR=`expr $COUNTYEAR + 1`
done
echo "------------------------------循环完成-----------------------------"