在RDBMS中没有主键的sqoop导入 [英] sqoop import without primary key in RDBMS
本文介绍了在RDBMS中没有主键的sqoop导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用sqoop将RDBMS表数据(表没有主键)导入配置单元吗?如果是,那么请你给sqoop import命令。
Can I import RDBMS table data (table doesn't have a primary key) to hive using sqoop ? If yes, then can you please give the sqoop import command.
我尝试过sqoop import general命令,但是失败了。
I have tried with sqoop import general command, but it failed.
提前致谢。
PK
推荐答案
如果您的表没有定义主键,那么您必须提供 -m 1
选项以导入数据,或者您必须提供 - split-by
参数一些列名,否则会给出错误:
If your table has no primary key defined then you have to give -m 1
option for importing the data or you have to provide --split-by
argument with some column name, otherwise it gives the error:
ERROR tool.ImportTool: Error during import: No primary key could be found for table <table_name>. Please specify one with --split-by or perform a sequential import with '-m 1'
然后你的sqoop命令看起来像
then your sqoop command will look like
sqoop import \
--connect jdbc:mysql://localhost/test_db \
--username root \
--password **** \
--table user \
--target-dir /user/root/user_data \
--columns "first_name, last_name, created_date"
-m 1
或
sqoop import \
--connect jdbc:mysql://localhost/test_db \
--username root \
--password **** \
--table user \
--target-dir /user/root/user_data \
--columns "first_name, last_name, created_date"
--split-by created_date
这篇关于在RDBMS中没有主键的sqoop导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文