Tuesday 28 June 2022

Hive: Get the database that user is in the Hive CLI

There are two options to print the database information that user is in.

 

Approach1 : Using the property hive.cli.print.current.db.

Execute below statement once you login to Hive Shell.

 

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

 

[cloudera@quickstart conf]$ hive

Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
WARNING: Hive CLI is deprecated and migration to Beeline is recommended.
hive> ;
hive> set hive.cli.print.current.db=true;
hive (default)>

hive (default)>: default is the database name here.

Approach 2: Start hive by executing below command.

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

[cloudera@quickstart conf]$ hive --hiveconf hive.cli.print.current.db=true

Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
WARNING: Hive CLI is deprecated and migration to Beeline is recommended.
hive (default)>



Previous                                                    Next                                                    Home

No comments:

Post a Comment