SHOW CREATE TABLE
描述
SHOW CREATE TABLE
返回用于创建给定表或视图的 CREATE TABLE 语句 或 CREATE VIEW 语句。对不存在的表或临时视图使用 SHOW CREATE TABLE
会引发异常。
语法
SHOW CREATE TABLE table_identifier [ AS SERDE ]
参数
-
table_identifier
指定表名或视图名,可以选择使用数据库名称进行限定。
语法:
[ database_name. ] table_name
-
AS SERDE
为 Hive SerDe 表生成 Hive DDL。
示例
CREATE TABLE test (c INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS TEXTFILE
TBLPROPERTIES ('prop1' = 'value1', 'prop2' = 'value2');
SHOW CREATE TABLE test;
+----------------------------------------------------+
| createtab_stmt|
+----------------------------------------------------+
|CREATE TABLE `default`.`test` (`c` INT)
USING text
TBLPROPERTIES (
'transient_lastDdlTime' = '1586269021',
'prop1' = 'value1',
'prop2' = 'value2')
+----------------------------------------------------+
SHOW CREATE TABLE test AS SERDE;
+------------------------------------------------------------------------------+
| createtab_stmt|
+------------------------------------------------------------------------------+
|CREATE TABLE `default`.`test`(
`c` INT)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ',')
STORED AS
INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
TBLPROPERTIES (
'prop1' = 'value1',
'prop2' = 'value2',
'transient_lastDdlTime' = '1641800515')
+------------------------------------------------------------------------------+