How to identify which database the user is using in hive CLI ?

Set hive.cli.print.current.db=true; sets the property in current hive session only. If one is out of the session the setting would be reset to default(false).

To be able to see the database name consistently accross sessions and users, root user can create .hiverc file in /etc/hive/conf with required parameter values. In this case add set hive.cli.print.current.db=true; These settings are now applied across all the users logging into hive CLI.

if the user is not root user, create .hiverc file in home directory /home/<>.The settings would be effective across all the hive sessions for the user.


To know which database user in

hive> set hive.cli.print.current.db=true

or start hive with

hive --hiveconf hive.cli.print.current.db=true

then the prompt will display

hive (db_name)>

There are two ways to know the current database. One temporary in cli and second one is persistently.

1) in CLI just enter this command: set hive.cli.print.current.db=true;

2) In hive-site.xml paste this code:


    <property>
    <name>hive.cli.print.current.db</name>
    <value>true</value>
    </property>
     

 

In second scenario, you can automatically display the Hive dabatabase name when you open terminal.

Tags:

Hive