Sqoop import multiple tables but not all

AM_Hawk picture AM_Hawk · Apr 7, 2016 · Viewed 7k times · Source

All the searches I've found show how to import one table or recommend the import-all-tables. What if I want 35 of 440 tables from my db. Can I just write one command and separate the tables by comma or do I have to put it in a script and copy and past the commands over and over and change the table name each time?

What I want to do:

echo "Sqoop Import"
--options-file ${path} 
--table tbl1,tbl2,tbl3\
--target-dir ${path}
--m 1\  

What I fear I may have to do:

echo "Sqoop Import"
--options-file ${path} 
--table tbl1\
--target-dir ${path}
--m 1

wait 

echo "Sqoop Import"
--options-file ${path} 
--table tbl2\
--target-dir ${path}
--m 1

Answer

hrobertv picture hrobertv · Apr 8, 2016

Apparently a sqoop developer thought like you. :)

You can use import-all-tables.
And then add --exclude-tables Comma separated list of tables to exclude from import process.

https://sqoop.apache.org/docs/1.4.0-incubating/SqoopUserGuide.html#id1766722