#!/bin/bash
# $1 表示库名
hive -e "use $1;"
# 每一个hive -e 都是一个新的hive客户端,所以要指定数据库。
tables=$(hive -e "use $1;show tables;")
table_0=()
i=0
for table in $tables
do
count=$(hive -e "select count(*) from $1.$table;")
if [ "$count" -eq "0" ]; then
# echo "表 table: $table ; 数量 count: $count";
table_0[i]=$table
let i=i+1
fi
done
echo " 最终结果输出 :"
echo ${table_0[*]}