gjin
gjin

Reputation: 929

How to create an empty copy of a table in hive

I have a table with lots of columns. I don't want to write something like

CREATE TABLE IF NOT EXISTS 
table1( 
col1 int, 
col2 String,
etc....)

Is there a fast way to create a table with the same structure, but without any data?

Upvotes: 6

Views: 9465

Answers (1)

leftjoin
leftjoin

Reputation: 38335

Try this:

CREATE TABLE some_db.T1 LIKE some_db.T2

See this manual: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableLike

Upvotes: 12

Related Questions