Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to get columns of list of tables in hive?
Labels:
- Labels:
-
Apache Hive
New Contributor
Created on ‎09-05-2017 10:28 AM - edited ‎09-16-2022 05:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i am trying to get the list of tables and columns using a single query. may i know how can i do that ?
I am looking for something like
ex: 'select * from dbc.columns where tables like 'E%'
How do we achive that in hive?
1 REPLY 1
Explorer
Created ‎11-09-2017 01:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can get this information from the metastore database:
hive=> SELECT "TBL_NAME", "COLUMN_NAME", "TYPE_NAME" FROM "TBLS" , "COLUMNS_V2" WHERE "TBL_ID"="CD_ID" UNION SELECT "TBL_NAME", "PKEY_NAME", "PKEY_TYPE" FROM "PARTITION_KEYS" p , "TBLS" t WHERE p."TBL_ID"=t."TBL_ID" ORDER BY "TBL_NAME"; TBL_NAME | COLUMN_NAME | TYPE_NAME ------------+-------------+----------- tableA | aaa | string tableA | bbb | string tableB | foo | string tableB | bar | int tableC | cola | string tableD | colb | string (6 rows)
