導入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