rogue-one
rogue-one

Reputation: 11587

Display the SQL definition of a hive view

How to display the view definition of a hive view in its SQL form. Most relational databases supports commands like

SHOW CREATE VIEW viewname;

Upvotes: 30

Views: 86096

Answers (4)

aryndin
aryndin

Reputation: 591

It is DESCRIBE [EXTENDED|FORMATTED] also. show create table doesn't give enough information sometimes, but DESCRIBE always does;

For a view, DESCRIBE EXTENDED or FORMATTED can be used to retrieve the view's definition. Two relevant attributes are provided: both the original view definition as specified by the user, and an expanded definition used internally by Hive.

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-DescribeTable/View/Column

Upvotes: 6

Anil
Anil

Reputation: 420

Yeah, You can use SHOW CREATE TABLE to display the CREATE VIEW statement that created a view.

Link for reference: Hive CREATE VIEW

Upvotes: 2

Jonathan
Jonathan

Reputation: 164

SHOW CREATE table ;

Even thought its a view's definition that you'd like to get, the 'table' keyword has to be mentioned.

Upvotes: 2

pensz
pensz

Reputation: 1881

Use show create table.

Read the hive manual for more detail.

Upvotes: 37

Related Questions