8

I know of these,

  • To get column names in a table we can fire:

    show columns in <database>.<table_name>
    
  • To get description of a table (including column_name, column_type and many other details):

    describe [formatted] <database>.<table_name>
    

I know that I can use the above query and filter the result to get the columns names and types. But I want to know if there is any direct command to get just the column names and types like select columns, column_type ...?

Ani Menon
  • 27,209
  • 16
  • 105
  • 126

2 Answers2

9

In HIVE you could use:

DESCRIBE FORMATTED [DatabaseName].[TableName] [Column Name];

This gives you the column data type and some stats of that column.

DESCRIBE [DatabaseName].[TableName] [Column Name];

This just gives you the data type and comments if available for a specific column.

Hope this helps.

Markus Appel
  • 3,138
  • 1
  • 17
  • 46
pramodM
  • 91
  • 1
  • 7
-1

Unlike traditional RDBMS, Hive stores metadata in a separate database. In most cases it is in MySQL or Postgres. If you have access to the metastore database, you can run SELECT on table TBLS to get the details about the tables and COLUMNS_V2 to get the details about columns.

Ramesh
  • 1,405
  • 10
  • 19