Hive drop table batched

if the hive version not support drop table tablename purge.

your drop table command will move data to .Trash in hdfs.

dfs .Trash;

drop table tablename;

dfs .Trash/Current;

#batch drop tables you want in hive.

hive --database databaseName -e "show tables '*_evan'" >>tables.txt;

---read line from txt files

while read line

do

#echo "drop table $line;"

hive --database databasename -e "drop table if exists $line;";

done < tables.txt

#output the drop table tableName to a hql file, then execute the file.

Looking for a job working at Home about MSBI
原文地址:https://www.cnblogs.com/huaxiaoyao/p/4346965.html