As of Hive 0.10 this patch-967 implements SHOW CREATE TABLE which "shows the CREATE TABLE statement that creates a given table, or the CREATE VIEW statement that creates a given view."
# !/bin/bash
for DB in `beeline --showHeader=false --outputformat=tsv2 -e "show databases;"`
do
for Tab in `beeline --showHeader=false --outputformat=tsv2 -e "use $DB; show tables;"`
do
beeline --showHeader=false --outputformat=tsv2 -e "show create table $DB.$Tab;" >$DB.$Tab.hql
done
done