sqoop - Sqoop Import All Tables - apache sqoop - sqoop tutorial - sqoop hadoop
How to import all tables from the RDBMS database server to the HDFS?
- Each table data is stored in a separate directory and the directory name is same as the table name.
- The import-all-tables tool imports a set of tables from an RDBMS to HDFS. Data from each table is stored in a separate directory in HDFS.
- For the import-all-tables tool to be useful, the following conditions must be met:
- Each table must have a single-column primary key or --autoreset-to-one-mapper option must be used.
- You must intend to import all columns of each table.
- You must not intend to use non-default splitting column, nor impose any conditions via a WHERE clause.
Syntax
Import control arguments:
Argument | Description |
---|---|
--as-avrodatafile | Imports data to Avro Data Files |
--as-sequencefile | Imports data to SequenceFiles |
--as-textfile | Imports data as plain text (default) |
--direct | Use direct import fast path |
--direct-split-size <n> | Split the input stream every n bytes when importing in direct mode |
--inline-lob-limit <n> | Set the maximum size for an inline LOB |
-m,--num-mappers <n> | Use n map tasks to import in parallel |
--warehouse-dir <dir> | HDFS parent for table destination |
-z,--compress | Enable compression |
--compression-codec <c> | Use Hadoop codec (default gzip) |
- These arguments behave in the same manner as they do when used for the sqoop-import tool, but the --table, --split-by, --columns, and --where arguments are invalid for sqoop-import-all-tables. The --exclude-tables argument is for +sqoop-import-all-tables only.
Example
- Let us take an example of importing all tables from the userdb database.
- The list of tables that the database userdb contains is as follows.
- The following command is used to import all the tables from the userdb database.
Note: If you are using the import-all-tables, it is mandatory that every table in that database must have a primary key field.
- The following command is used to verify all the table data to the userdb database in HDFS
- It will show you the list of table names in userdb database as directories.