sqoop import multiple tables sqoop import multiple tables hadoop hadoop

sqoop import multiple tables


U can use " import-all-tables " option to load all tables into HDFS at one time .

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

if we want to exclude some tables to load into hdfs we can use " --exclude-tables " option

Ex:

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

If we want to store in a specified directory then u can use " --warehouse-dir " option

Ex:

sqoop import-all-tables --connect jdbc:mysql://localhost/sqoop --username root --password hadoop --warehouse-dir '/Sqoop'


  1. Assuming that the sqoop configuration for each table is the same, you can list all the tables you need to import and then iterate over them launching sqoop jobs (ideally launch them asynchronously). You can run the following to fetch the list of tables from Oracle:SELECT owner, table_name FROM dba_tables reference

  2. Sqoop does offer an option to import all tables. Check this link. There are some limitations though.

  3. Modify sqoop source code and recompile it to your needs. The sqoop codebase is well documented and nicely arranged.


--target-dir is not a valid option when using import-all-tables.

To import all tables in particular directory, Use --warehouse-dir instead of --target-dir.

Example:

$ sqoop import-all-tables --connect jdbc:mysql://localhost/movies --username root --password xxxxx --warehouse-dir '/user/cloudera/sqoop/allMoviesTables' -m 1