Hive, how do I retrieve all the database's tables columns

前端 未结 2 1531
暗喜
暗喜 2020-12-18 03:32

I want to write the equivalent of this sql request in Hive :

select * from information_schema.columns where table_schema=\'database_name\'
2条回答
  •  萌比男神i
    2020-12-18 04:06

    If you want to have the ability to run such queries that return hive metadata, you can setup Hive metastore with MySQL, metadata used in Hive is stored in a specific account of MySQL.

    You will have to create a user of MySQL for hive by doing CREATE USER 'hive'@'metastorehost' IDENTIFIED BY 'mypassword'.

    Then you will find tables like COLUMNS_VS with the info you are looking for.

    An example query to retrieve all columns in all tables could be: SELECT COLUMN_NAME, TBL_NAME FROM COLUMNS_V2 c JOIN TBLS a ON c.CD_ID=a.TBL_ID

    Alternatively, you can access this information via REST calls to WebHCat see wiki for more info.

提交回复
热议问题