Sqoop Eval Command With Example


Sqoop Eval Command With Example

This post describes how to use the Sqoop 'eval' tool. It allows users to execute user-defined queries against respective database servers and preview the result in the console. So, the user can expect the resultant table data to import. Using eval, we can evaluate any type of SQL query that can be either DDL or DML statement.

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

Select Query Evaluation

Using eval tool, we can evaluate any type of SQL query. Let us take an example of selecting limited rows in the employee table of db database. The following command is used to evaluate the given example using SQL query.




$ sqoop eval \
--connect jdbc:mysql://localhost/userdb \
--username root \
--password root \
--query "SELECT * FROM employee LIMIT 3"


Insert Query Evaluation

Sqoop eval tool can be applicable for both modeling and defining the SQL statements. That means, we can use eval for insert statements too. The following command is used to insert a new row in the employee table of db database.




$ sqoop eval \
--connect jdbc:mysql://localhost/userdb \
--username root \
--password root \
-e "INSERT INTO employee VALUES(1207,'Raju','UI dev',15000,'TP')"







Have any Question or Comment?

Leave a Reply

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