gpt4 book ai didi

database - 如何编写查询以查找数据库中具有特定列名的所有表? hive

转载 作者:行者123 更新时间:2023-12-02 21:06:24 24 4
gpt4 key购买 nike

我有一个约有400个表的数据库,我需要按列名查找所有表。基本上我需要这样的东西:

select <tables> from <database> where table.columnName='tv';

我怎样才能做到这一点?

最佳答案

下面的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

关于database - 如何编写查询以查找数据库中具有特定列名的所有表? hive ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41758692/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com