Get the create table statement for an existing Hive table using Show create table
The SHOW statement is a flexible way to get the information about existing objects in Hive. One of the Show statement is Show create table which is used to get the create table statement for the existing Hive table.
Show Create Table
Show Create Table which generates and shows the Create table statement for the given table.
Syntax for Show create table
1 |
Show create table [table_name] |
Example
The table cust_txn is already exist in hive as below.
If we ran the show create table statement for this table cust_txn,It will generate the Create table statement as below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
hive> show create table cust_txn; OK CREATE TABLE `cust_txn`( `emp_id` bigint, `name` string, `txn_amt` bigint) ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n' NULL DEFINED AS '' STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' LOCATION 'hdfs:apps/hive/warehouse/cust_txn' TBLPROPERTIES ( 'COLUMN_STATS_ACCURATE'='{\"BASIC_STATS\":\"true\"}', 'auto.purge'='true', 'numFiles'='2', 'numRows'='2', 'rawDataSize'='18', 'totalSize'='36', 'transient_lastDdlTime'='1559327044') Time taken: 0.214 seconds, Fetched: 22 row(s) |
Recommended Articles