Wednesday, December 21, 2011

Extract / Get DDL of Hive tables

Recent issue I came across when we need to migrate Hive tables from one server to another.. (even from a dev to prod environment) as usual we havent preserved the DDL for the Hive tables present..

Googled and came across this jira https://issues.apache.org/jira/browse/HIVE-967

Step by step

1. download the HiveShowCreateTable.jar from jira
2. Copy it to the server which has Hive (even your local directory is fine)
3. Run as following (the syntax in the txt file of Jira doesnt work because of its reference to a non-existent jar file)

hive --service jar HiveShowCreateTable.jar com.media6.hive2rdbms.job.ShowCreateTable -D db.name=default -D table.name=poc_detail 2>/dev/null

ta..da.. we get the DDL of the provided table :-)

Thanks to Ed Capriolo who created this code..

1 comment: