表结构备份
10.138.87.7所有库的表结构备份,导出到文件复制表结构的语句
脚本1:
#!/bin/bash
hive -e "show tables;" > tables.txt
sleep(2)
cat tables.txt |while read eachline
do
hive -e "show create table $eachline" >>tablesDDL.txt
done
脚本2 针对hive的:
#!/bin/bash
# bak the hive tables
hive -e "show databases "> database.txt
rm -rf bak_table.hql bak_table_create.txt
while read database
do
echo "the database is :$database "
echo "xxxxxxxxxxxxxxxxxxxxxxxxx database: $database xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">> bak_table_create