Apache Sqoop List Databases Command with Examples

Welcome to DataFlair Apache Sqoop Tutorial series. This article first provides a short introduction to Sqoop List Databases. Later on, the article will explain the purpose, syntax, arguments, and many more.

The article also covers the example invocation for the Sqoop List Databases tool to make your understanding better.

Let us first see an introduction to Sqoop.

 

What is Sqoop?

SQOOP is an open-source project of the Apache Software Foundation. It stands for SQL to Hadoop. Sqoop is a tool that is specially designed for transferring data between the Hadoop ecosystem and the RDBMS like MySQL, Oracle, SQL Server, etc.

It is basically a command-based interface where we use Sqoop commands for importing or exporting data from and to the RDBMS and Hadoop ecosystem.

What is Sqoop List Databases?

The Sqoop List Databases is a tool that executes and parses the “SHOW DATABASES” query against the database server. This lists out the entire database present in the database server.

The primary purpose of this tool is to list the database schemas present on the server.

Syntax of Sqoop List Databases

Syntax for executing this tool is:

$ sqoop list-databases (generic-args) (list-databases-args)
$ sqoop-list-databases (generic-args) (list-databases-args)

The Hadoop generic arguments must come before any other list-databases arguments. Although we can pass the list-databases arguments in any order with respect to each other.

Common arguments are:

Argument Description
–connect <jdbc-uri> Specify JDBC connect string
–connection-manager <class-name> Specify the connection manager class to be used
–driver <class-name> Manually specify JDBC driver class to use
–hadoop-mapred-home <dir> Override $HADOOP_MAPRED_HOME
–help Print usage instructions
–password-file It will set the path for a file containing authentication password
-P Read password from console
–password <password> Set authentication password
–username <username> Set authentication username
–verbose It will print more information while working
–connection-param-file <filename> Optional properties file that provides connection parameters
–relaxed-isolation Set connection transaction isolation to read uncommitted for the mappers.

Sqoop List Databases Example Invocations

For example, we can list the database schemas available on the MySQL server by using the below command:

$ sqoop list-databases
–connect jdbc:mysql://localhost/
–username “root”
–password “root”

Note: This works only with the HSQLDB, MySQL, and Oracle. When using it with Oracle, then it is necessary that the user who is connecting to the database must have the DBA privileges.

Summary

I hope after reading this article, you have understood the Sqoop List Databases tool. You have also seen the List Databases syntax as well as its purpose.

Moreover, the article had covered list databases arguments for the practical uses. We have also provided an example invocation to make you understand it easily.