How to list all hive databases being in use or created so far?
Asked Answered
C

6

24

Similar to SHOW TABLES command, do we have any such command to list all databases created so far?

Collect answered 5/11, 2013 at 4:33 Comment(0)
G
42

This page mentions the command SHOW DATABASES.

From the manual:

SHOW (DATABASES|SCHEMAS) [LIKE identifier_with_wildcards];

SHOW DATABASES lists all of the databases defined in the metastore. The optional LIKE clause allows the list of databases to be filtered using a regular expression. Wildcards in the regular expression can only be '' for any character(s) or '|' for a choice. Examples are 'employees', 'emp', 'emp*|*ees', all of which will match the database named 'employees'.

Gyratory answered 5/11, 2013 at 4:39 Comment(1)
gotcha! I should have tried before posting it here. It works!! thanks for your time.Collect
M
2

show databases;

The above query will list all the databases available in the hive metastore.

Meyers answered 17/10, 2018 at 13:10 Comment(0)
B
0

For any such queries involving metadata of the objects, you must use the hive metastore deployed on databases such as MySQL or likes of MySQL. You can use the hive database installed on metastore and use the INFORMATION_SCHEMA views/tables for your queries

Bopp answered 7/10, 2015 at 13:17 Comment(0)
F
0

If you need to search database based on wildcards then we can use below commands

show databases like '%<DB_NAME>'

use your database name in place of <DB_NAME>

Folberth answered 23/7, 2021 at 7:53 Comment(1)
Please provide a detailed explanation to your answer, in order for the next user to understand your answer better. Also, provide a basic coverage of the content of your link, in case it stops working in the future.Bunn
H
0

This will work

hive>show databases like 'office*';

It will display all databases whose name start wirh

Howes answered 17/2, 2022 at 8:59 Comment(0)
A
-2

show databases;

This query should work

Axillary answered 23/7, 2021 at 11:22 Comment(1)
This is the same solution as in this other answer.Chore

© 2022 - 2024 — McMap. All rights reserved.