-----------------------mysql to hive(一、先建表,再导入数据)------------------------------
在hive中创建表kb15.student_mysql,数据结构与mysql中student相同
[root@mihaoyu151 ~]# sqoop create-hive-table \
> --connect jdbc:mysql://mihaoyu151:3306/mybatisdb \
> --username root \
> --password root \
> --table student \
> --hive-table kb15.student_mysql
-----------------------------------------------------
[root@mihaoyu151 ~]# sqoop import \
> --connect jdbc:mysql://mihaoyu151:3306/mybatisdb \
> --username root \
> --password root \
> --table student \
> --hive-table kb15.student_mysql \
> --hive-import \
> --m 1
------------------------mysql to hive(二、同时建表、导入数据)-----------------------------
[root@mihaoyu151 ~]# sqoop import \
> --connect jdbc:mysql://mihaoyu151:3306/mybatisdb \
> --username root \
> --password root \
> --table student \
> --hive-import \
> --hive-database kb15 \
> --m 1
-----------------------where------------------------------
[root@mihaoyu151 ~]# sqoop import \
> --connect jdbc:mysql://mihaoyu151:3306/mybatisdb \
> --username root \
> --password root \
> --table student \
> --where "telephone='13613309876' and classId=3" \
> --target-dir /sqoop/demo3 \
> --delete-target-dir \
> --m 1
------------------------query-----------------------------
[root@mihaoyu151 ~]# sqoop import \
> --connect jdbc:mysql://mihaoyu151:3306/mybatisdb \
> --username root \
> --password root \
> --query 'select id,name,age,gender,telephone,email,classId from student where id>3 and classId=1 and $CONDITIONS' \
> --target-dir /sqoop/demo6 \
> --delete-target-dir \
> --fields-terminated-by '\t' \
> --split-by classId \
> --m 1
----------------------增量导入-------------------------------
[root@mihaoyu151 ~]# sqoop import \
> --connect jdbc:mysql://mihaoyu151:3306/mybatisdb \
> --username root \
> --password root \
> --table student \
> --target-dir /sqoop/incre1 \
> --incremental append \
> --check-column id \
> --last-value 9 \
> --m 1
------------------incremental增量导入	lastmodified <append, merge-key>-----------------------------------
[root@mihaoyu151 ~]# sqoop import \
> --connect jdbc:mysql://mihaoyu151:3306/mybatisdb \
> --username root \
> --password root \
> --table student2 \
> --target-dir /sqoop/incre2 \
> --incremental lastmodified \
> --check-column last_mod \
> --last-value "2021-11-23 11:07:05" \
> --append \
> --m 1
------------------incremental增量导入	lastmodified <append, merge-key>-----------------------------------
[root@mihaoyu151 ~]# sqoop import \
> --connect jdbc:mysql://mihaoyu151:3306/mybatisdb \
> --username root \
> --password root \
> --table student2 \
> --target-dir /sqoop/incre3 \
> --incremental lastmodified \
> --check-column last_mod \
> --last-value "2021-11-23 11:11:32" \
> --merge-key id \
> --m 1
-----------------------------------------------------
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐