30

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

SHOW CREATE VIEW viewname;

rogue-one
  • 11,259
  • 7
  • 53
  • 75

4 Answers4

37

Use show create table.

Read the hive manual for more detail.

pensz
  • 1,871
  • 1
  • 13
  • 18
6

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

aryndin
  • 591
  • 5
  • 18
2

SHOW CREATE table ;

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

Jonathan
  • 144
  • 4
  • 13
2

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

Link for reference: Hive CREATE VIEW

Community
  • 1
  • 1
Anil
  • 420
  • 2
  • 16