Summary -

In this topic, we described about the Use Database with detailed example.

By default after Hive installation, the default database is in use. Once the user defined database successfully created, user needs use the database by using the USE command. USE sets the current database for all subsequent HiveQL statements.

Syntax -

Hive> USE databse_name;

Below example to shows how to use the std_db created above.

Hive> USE std_db;

From this point, all the tables going to created will be stored under std_db. To revert to the default database at any point of time, use the keyword "default" instead of a database name.

Any point of time, to check the current database, use SELECT statement like below.

Hive> SELECT current_databse();