Cluster Migration hive table (no built table statement)

Production account recovery, we need to migrate all data tables to the test environment! ! !
Hundreds of tables, could not find the original construction of the table statement to fend for themselves to find the solution.
Baidu for a long time, finally decided to build the table statement downloaded from the cluster by the shell:
New list_tables.sql

use db;
show tables;

New show_create.sql

use db;
show create table ${hiveconf:table};

download_test.sh

#! /bin/bash
hive -S -f list_tables.sql > tables_name.txt
cat tables_name.txt | while read eachline
do
    hive -hiveconf table=${eachline} -S -f show_create.sql >> tables_structure.txt
    echo >> tables_structure.txt
done
hdfs dfs -put *.txt /user/asmp/shell
rm -rf tables_name.txt tables_structure.txt

Download the final construction of the table statement to tables_structure.txt, after simple treatment to perform the test cluster.

Note:
the table name and the field does not support Chinese comments COMMENT '???', the best manual processing.

Published 118 original articles · won praise 25 · Views 150,000 +

Guess you like

Origin blog.csdn.net/lhxsir/article/details/90448768