-- hive 输出库中表结构
-- 输出所有表名
hive -e "use xx;show tables;" > tables.txt
vim echo_table.sh
-- 输出所有表结构
#!/bin/bash
echo 'use xx;' >> tablesDDL.sql
cat tables.txt |while read eachline
do
hive -e "use xx;show create table $eachline" >>tablesDDL.sql
echo ';' >> tablesDDL.sql
done
-- 修改执行权限
chmod 777 echo_table.sh
nohup ./echo_table.sh > myout.file 2>&1 &
-- 将文件的存储格式处理一下,防止产生序列化和压缩格式的问题
-- 把phoenix 和hbase 以及view拿出来
-- 对hive表处理 删除行
sed -i "/^ 'org.apache./d" tablesDDL01
sed -i "/^OUTPUTFORMAT/d" tablesDDL01
sed -i "/^LOCATION/d" tablesDDL01
sed -i "/^ 'hdfs:/d" tablesDDL01
sed -i "/^TBLPROPERTIES/d" tablesDDL01
sed -i "/^ 'transient_lastDdlTime/d" tablesDDL01
-- 替换行
sed -i "s/^STORED AS INPUTFORMAT.*/STORED AS ORC/" tablesDDL01