#!/bin/bash
#set -x
DB=$1
#获取hive表定义
ret=$(hive -e "use ${DB};show tables;"|grep -v _es|grep -v _hb|grep -v importinfo)
for tem in $ret;
do
echo ${tem}_tmp
hive -e "use ${DB};drop table ${tem}_tmp"
hive -e "use ${DB};create table ${tem}_tmp_1 as select * from ${tem}"
hive -e "use ${DB};alter table ${tem} rename to ${tem}_tmp"
hive -e "use ${DB};alter table ${tem}_tmp_1 rename to ${tem}"
done
impala-shell -q 'invalidate metadata' -i hslave1
#使用了impala所以要更新