我找到的所有搜索都显示了如何导入一个表或推荐import-all-tables。如果我需要db中的440个表中的35个,该怎么办?我可以只编写一个命令并用逗号分隔表,还是必须将它放在脚本中并一遍又一遍地复制并通过命令并每次更改表名?
我想做的事:
echo "Sqoop Import"
--options-file ${path}
--table tbl1,tbl2,tbl3\
--target-dir ${path}
--m 1\
我担心我可能要做的事情:
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
显然,一个sqoop开发人员和你一样。 :)
您可以使用import-all-tables。 然后添加--exclude-tables以逗号分隔的表列表,以便从导入过程中排除。
https://sqoop.apache.org/docs/1.4.0-incubating/SqoopUserGuide.html#id1766722
您还可以使用相同的命令将Hive导入应用为:
sqoop import-all-tables --connect jdbc:mysql://your_ip_address:3306/database_name --driver com.mysql.jdbc.Driver --username root --warehouse-dir temp_dir_for_staging --hive-import --hive-overwrite --hive-database hive_db --exclude-tables list_of_tables_to_be_excluded -m 1
记得在Hive中你需要中转区域。
使用--exclude-tables "table1,table2"
选项忽略table1和table2。
不要在表名之间添加空格(又名."table1, table2"
)