1

Is there a way to catch all schema + table name info in a single command through Hive in a similar way to

SELECT *  FROM information_schema.tables

from the PostgreSQL world?

show databases and show tables combined in a loop [here an example] is an answer, but I'm looking for a more compact way to have the same result in a single command.

Terru_theTerror
  • 4,918
  • 2
  • 20
  • 39

1 Answers1

-1

It's been long I have worked on Hive Queries but as far as I remember you can probably use

hive> desc formatted tableName;

or

hive> describe formatted tableName;

It will give you all the relevant information related to the Table like the Schema, Partition info, Table Type like Managed Table, etc

I am not sure If you are particularly looking for this ??

There is another way to query Hive Tables, is writing Hive Scripts which can be called from Hadoop Terminal rather than from Hive Terminal itself.

std]$ cat sample.hql or vi sample.hql 
    use dbName;
    select * from tableName;
    desc formatted tableName;

# this hql script can be called from outside the hive terminal
std]$ hive -f sample.hql

or, without even have to write script file you can probably query hive as

std]$ hive -e "use dbName; select * from emp;" > text.txt or >> to append

On the Database level, you can probably query as :

hive> use dbName;
hive> set hive.cli.print.current.db=true;
hive(dbName)> describe database dbName;

it will bring metadata from MySQL(metastore) about the Database.

DHEERAJ
  • 571
  • 6
  • 9
  • Thank you for the answer, but it looks like that this method is usefull to collect info table by table and not for all tables stored on hadoop – Terru_theTerror Jun 10 '20 at 10:21