Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

sqoop import multiple table

sqoop import multiple table

Rising Star

Hi,

I know the command to import a data table with Sqoop is :

sqoop import \ --connect "jdbc:jtds:sqlserver://xxxx:xxxx;databaseName=xxxx;user=xxxx;password=xxxx;instance=xxxx" \ --driver net.sourceforge.jtds.jdbc.Driver \ --username xxxx \ --table table_name \ --target-dir /test \ --as-textfile \ --fields-terminated-by '\t' \ --verbose

But I would like to learn how to change this command to import the table several of my choice ?
thank you
5 REPLIES 5

Re: sqoop import multiple table

Super Guru

@alain TSAFACK

1. You can fetch list of all tables and iterate sqoop command for each table or table of your choice using simple shell script (assuming sqoop configuration is same for each table )

2. Sqoop does give us option to fetch all tables. Please see below documentation link

http://sqoop.apache.org/docs/1.4.2/SqoopUserGuide.html#_literal_sqoop_import_all_tables_literal

Re: sqoop import multiple table

Rising Star

Hello Kuldeep Kulkarni ,

thank you for your response . But I do like to know that iteration with Sqoop on table of my choice?

Thk

Re: sqoop import multiple table

Mentor

you can do something like this

for i in tbl1 tbl2 tbl3

do

sqoop import $i

done

or maybe try this https://community.hortonworks.com/content/kbentry/23602/sqoop-fetching-lot-of-tables-in-parallel.htm...

Re: sqoop import multiple table

Super Guru

Re: sqoop import multiple table

New Contributor

One alternative option is to use import all table and in last use -- exclude-table and give all table that you don't want to import as table1,table2,...

You can use this in case maximum table you want to import .

Don't have an account?
Coming from Hortonworks? Activate your account here