我有一个包含大约400个表的数据库,我需要查找按列名搜索的所有表。基本上我需要这样的东西:
select <tables> from <database> where table.columnName='tv';
我该怎么做?
答案 0 :(得分:0)
下面的shell脚本会给你想要的结果:
output=""|
hive -e 'show tables in <database_name>' |
while read line
do
echo "TABLE NAME : $line"
if eval "hive -e 'describe <database_name>.$line'" | grep -q "tv"; then
output+="Required table name: $line"'\n'
else
output+=""
fi
echo -e "$output"
done