Apache Sqoop List-Tables Command With Example

posted on Nov 20th, 2016

Apache Sqoop

Apache Sqoop is a command-line interface application for transferring data between relational databases and Hadoop. It supports incremental loads of a single table or a free form SQL query as well as saved jobs which can be run multiple times to import updates made to a database since the last import. Imports can also be used to populate tables in Hive or HBase. Exports can be used to put data from Hadoop into a relational database. Sqoop got the name from sql+hadoop. Sqoop became a top-level Apache project in March 2012.

Pre Requirements

1) A machine with Ubuntu 14.04 LTS operating system.

2) Apache Hadoop pre installed (How to install Hadoop on Ubuntu 14.04)

3) MySQL Database pre installed (How to install MySQL Database on Ubuntu 14.04)

4) Apache Sqoop pre installed (How to install Sqoop on Ubuntu 14.04)

Sqoop List-Tables Command With Example

This post describes how to list out the tables of a particular database in MySQL database server using Sqoop. Sqoop list-tables tool parses and executes the 'SHOW TABLES' query against a particular database. Thereafter, it lists out the present tables in a database.

Step 1 - Change the directory to /usr/local/hadoop/sbin

$ cd /usr/local/hadoop/sbin

Step 2 - Start all hadoop daemons.

$ start-all.sh

Step 3 - The JPS (Java Virtual Machine Process Status Tool) tool is limited to reporting information on JVMs for which it has the access permissions.

$ jps

Step 4 - Change the directory to /usr/local/sqoop/bin

$ cd /usr/local/sqoop/bin

List-Tables (See, How to use Import command)

Sample Query

The following command is used to list all the tables in the userdb database of MySQL database server.

$ sqoop list-tables \
--connect jdbc:mysql://localhost/userdb \
--username root \
--password root 

Apache Sqoop List-Tables Command With Example

You can also list-tables using eval command.

$ sqoop eval \
--connect jdbc:mysql://localhost/userdb \
--username root \
--password root \
--query "show tables"

Please share this blog post and follow me for latest updates on

facebook             google+             twitter             feedburner

Previous Post                                                                                          Next Post

Labels : Apache Sqoop Installation on Ubuntu   Apache Sqoop Import Command Example   Apache Sqoop Export Command Example   Apache Sqoop Job Command Example   Apache Sqoop Codegen Command Example   Apache Sqoop Eval Command Example   Apache Sqoop List-tables Command Example