Sqoop CMD to export MYSQL table to Hive

Here is the handy command to run quickly without referring  the official Sqoop long help !! , This  command needs  minimum import control argument for a faster export  and we are assuming that  same table doesn’t  exist in Hive as well , else command will fail by throwing the error “AlreadyExistsException(message:Table struct_data already exists)

Sqoop Syntax –

–connect <jdbc-uri>  –username <???>  –password <???>  –split-by <column-name> –table <table-name>  –hive-import  –create-hive-table –hive-table <table-name>

Sqoop Example  –

Database Name – test

Username – testuser

password – testPW

Table Name – test_table

MYSQL table Column name – id 

Hive Database Name –  XYZ

sqoop import –connect jdbc:mysql://111.21.15.114/test –username testuser –password testPW –split-by id –table test_table  –hive-import  –create-hive-table  –hive-table XYZ.test_table

 

 

Leave a Reply

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

Name *