sqoop import for multiple table



0

how to i write a shell script for import multipal table in sqoop . please give me example of it . 


1 Answer(s)


0

Hi Rakesh,

You can use the sqoop with import all table parameter to fetch all the tables at once(considering all table has same configuration):

Sample Code:

sqoop import-all-tables --connect jdbc:mysql://localhost/sqoop --username root --password hadoop  --target-dir 'rakesh/sqoop/alltables'

If you want to exclude certain table while importing, you can use --excldue:

sqoop import-all-tables --connect jdbc:mysql://localhost/sqoop --username root --password hadoop  --target-dir 'rakesh/sqoop/alltables'  --exclude-tables <table1>,<tables2>

If you want script to import lot of tables in parallel with Sqoop and write them to Hive:

Check the link: https://github.com/sourygnahtw/hadoopUtils/blob/master/scripts/sqoop/sqoopTables.sh

Hope this helps.

Thanks.