Impala Select a Database Using Hue Browser

Boost your career with Free Big Data Courses!!

While working on Impala, it is essential to select one database among the available databases. So, in this article “Introduction to Impala Select a Database”, we will learn what we mean by Impala Select a Database. Afterward, we will learn its syntax, usage as well as an example to understand it well.

So, let’s know how Impala Select a Database.

How Impala Select a Database

The word “Select a Database”, means we need to select one among the available databases, as soon as we get connected to Impala. So, in order to switch the current session to another database, we use The USE DATABASE Statement of Impala.

Impala USE Statement

Basically, we begin in a database named default, whenever we connect to an Impala instance. In order to switch to another database within an impala-shell session, Issue the statement USE db_name.

Wherever any CREATE TABLE, INSERT, SELECT, or other statements act when you specify a table without prefixing it with a database name, is the current database.

i. Usage
There are some suitable situations in which Switching the default database is convenient, such as:

  • While we want to avoid qualifying each reference to a table with the database name like SELECT * FROM t1 JOIN t2 instead of SELECT * FROM db.t1 JOIN db.t2.
  • Also, in order to do a sequence of operations all within the same database. Like creating a table, inserting data, and querying the table.

Moreover, specify the option -d db_name for the impala-shell command, to issue a USE statement automatically or to start the impala-shell interpreter for a particular database.

However,  without hardcoding a USE statement into the SQL source, we can use the -d option to run SQL scripts. Like setup or test scripts, against multiple databases.

A Syntax of Impala USE Statement

Here, is the syntax of USE Statement, below;

USE db_name;

 

Example of USE statement

Now, let’s understand it with the following example of USE statement.
So, create a database with the name sample_database, at first. Like below.
For Example,

> CREATE DATABASE IF NOT EXISTS sample_database;

Hence, it will create a new database. Further, it provides the following output;

Query: create DATABASE IF NOT EXISTS my_db2

Fetched 0 row(s) in 2.73s

Then, we can observe the name of the newly created database, through SHOW DATABASES statement,  while verifying the list of databases.

> SHOW DATABASES;

Query: show DATABASES
+———————–+
| name                  |
+———————–+
| _impala_builtins      |
| default               |
| my_db                 |
| sample_database       |
+———————–+
Fetched 4 row(s) in 0.11s
Further, using the USE Statement,  switch the session to the newly created database (sample_database).

> USE sample_database;

As a result, the current context will change to sample_database. Also, displays a message.

Query: use sample_database

Selecting a Database using Hue Browser

There are several steps we can follow, in order to Select a Database using Hue Browser, such as;

  • There is a drop-down menu On the left-hand side of the Query Editor of Impala.
  • Then after clicking on the drop-down menu, you will find the list of all the databases in Impala.
  • Further, select the database to which you need to change the current context.

This was all about Impala Select a Data Base. Hope you like our explanation.

Conclusion

As a result, we have seen the whole concept of Impala Select a Database. Still, if any query you want to ask regarding Impala Select a Database, please ask through the comment section.

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *