天天看点

sqoop导入mysql表数据到HIVE

导入mysql表数据到HIVE

将关系型数据的表结构复制到hive中

bin/sqoop create-hive-table

–connect jdbc:mysql://node-1:3306/userdb

–table emp_add

–username root

–password hadoop

–hive-table test.emp_add_sp

其中 --table emp_add为mysql中的数据库sqoopdb中的表

–hive-table emp_add_sp 为hive中新建的表名称

从关系数据库导入文件到hive中

bin/sqoop import

–connect jdbc:mysql://node-1:3306/userdb

–username root

–password hadoop

–table emp_add

–hive-table test.emp_add_sp

–hive-import

–m 1

导入表数据子集

bin/sqoop import

–connect jdbc:mysql://node-21:3306/sqoopdb

–username root

–password hadoop

–where “city =‘sec-bad’”

–target-dir /wherequery

–table emp_add --m 1

bin/sqoop import

–connect jdbc:mysql://node-1:3306/userdb

–username root

–password hadoop

–target-dir /wherequery12

–query ‘select id,name,deg from emp WHERE id>1203 and $CONDITIONS’

–split-by id

–fields-terminated-by ‘\t’

–m 1

增量导入

bin/sqoop import

–connect jdbc:mysql://node-21:3306/sqoopdb

–username root

–password hadoop

–table emp --m 1

–incremental append

–check-column id

–last-value 1205

继续阅读