List Tables in Apache Sqoop with Arguments

Sqoop List Tables is a tool for executing the ‘SHOW TABLES’ query against the particular database. In this Sqoop List Tables tutorial, you will learn what it is, purpose, syntax, arguments, and examples.

So let’s start!!!

Sqoop- List Tables

What is a Sqoop List Tables?

  • It is a tool that lists out all the tables of a particular database in the MySQL database server.
  • This tool parses and executes ‘SHOW TABLES’ query against the particular database. Then it lists out all the present tables in a particular database.
  • Its primary purpose is to list the tables present in a database.

Sqoop List Tables Syntax and Arguments

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

We have to pass the Hadoop generic arguments before any list-tables arguments. But we can pass the arguments in any order with respect to each other.

Common Arguments are:

Argument Description
–connect <jdbc-uri> It will specify the JDBC connect string
–connection-manager <class-name> It will 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 the file containing authentication password
-P It will read the password from console
–password <password> Set authentication password
–username <username> Set authentication username
–verbose This option prints more information when working
–connection-param-file <filename> This argument specify the optional properties file which provides the connection parameters
–relaxed-isolation It will set the connection transaction isolation in order  to read the uncommitted for the mappers.

Sqoop List Tables Example Invocations

Example 1: In this example, we are trying to present list tables in the database named “demo”:

$ sqoop list-tables --connect jdbc:mysql://localhost/demo

The output of the above command will be:
emp_info
dept_info
job_descr

Example 2: In case of the postgresql, the list tables command with the common arguments retrieves “public” schema only. For the custom schema, we have to use –schema arguments for listing tables of the particular schema.

$ sqoop list-tables --connect jdbc:postgresql://localhost/demo  --username root -P root --schema payrolldept

Summary

After reading this article, I hope you clearly understood how we can list all the tables in a particular database by using Sqoop.

The Sqoop List Tables is a tool that lists out all the tables of a particular database in the MySQL database server. The article had explained its syntax and common argument with the help of example.

Do not forget to share your experience with us.