1. 程式人生 > >shell批量匯出hive表結構

shell批量匯出hive表結構

#!/bin/bash
rm -rf databases.txt
hive -e " show databases; exit ;" > databases
#sleep(2)
rm -rf ./tables/*
for database in `cat databases`
do
  {
  hive -e " use $database ;  show tables ; exit ;" > ./tables/$database
  rm -rf ./desc_table/$database
  for table in `cat ./tables/$database`
  do
     hive -e "use $database ; show create table $table ;" > ./desc_table/$database
  done
  }&
done
wait