#!/bin/bash
rm -f tableNames.txt
rm -f HiveTableDDL.txt
hive -e "use $1; show tables;" > tableNames.txt
cat tableNames.txt |while read LINE
do
hive -e "use $1;show create table $LINE" >>HiveTableDDL.txt
echo -e "\n" >> HiveTableDDL.txt
done
echo "Table DDL generated"
我这样跑
bash-4.1$ sh hive_table_ddl.sh copyreqtb
16/08/04 08:15:16 WARN conf.HiveConf: HiveConf of name hive.exec.warehousedir does not exist
16/08/04 08:15:16 WARN conf.HiveConf: HiveConf of name hive.server2.authentication.pam.profiles does not exist
log4j:WARN No appenders could be found for logger (org.apache.hadoop.hive.common.LogUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Logging initialized using configuration in file:/mapr/datalake/other/optum-optumcloud-link_rpt/hive/conf/hive-log4j.properties
OK
Time taken: 1.288 seconds
OK
Time taken: 0.257 seconds, Fetched: 182 row(s)
hive_table_ddl.sh: line 11: syntax error: unexpected end of file
如图所示,我想获取数据库中所有表的create table语句。所以,我写得像这样并执行。如图所示,给我错误,有些身体可以帮助哪里出错?感谢。