全部导入
bin/sqoop import \
--connect jdbc:mysql://hadoop102:3306/company \
--username root \
--password 000000 \
--table staff \
--target-dir /user/company \
--num-mappers 1 \
--fields-terminated-by "\t"
--部分导入
bin/sqoop import \
--connect jdbc:mysql://hadoop102:3306/company \
--username root \
--password 000000 \
--target-dir /user/company \
--num-mappers 1 \
--fields-terminated-by "\t"
--query 'select name,sex from staff where id <=1 and $CONDITIONS;'
--query "select name,sex from staff where id <=1 and \$CONDITIONS;"
指定导入列
bin/sqoop import \
--connect jdbc:mysql://hadoop102:3306/company \
--username root \
--password 000000 \
--table staff \
--columns id,sex \
--target-dir /user/company \
--num-mappers 1 \
--fields-terminated-by "\t"
关键字删选
bin/sqoop import \
--connect jdbc:mysql://hadoop102:3306/company \
--username root \
--password 000000 \
--target-dir /user/company \
--num-mappers 1 \
--fields-terminated-by "\t"
--table staff \
--colums id,sex \
--where "id=1"
--导入到hive
bin/sqoop import \
--connect jdbc:mysql://hadoop102:3306/company \
--username root \
--password 000000 \
--table staff \
--num-mappers 1 \
--hive-import \
--fields-terminated-by "\t"
--hive-overwrite \
--hive-table staff_hive
--导入至hbase
bin/sqoop import \
--connect jdbc:mysql://hadoop102:3306/company \
--username root \
--password 000000 \
--table staff\
--columns "id,name,sex" \
--column-family "info" \
--hbase-creat-table \
--hbase-row-key "id" \
--habse-table "hbase_company" \
--num-mappers 1 \
--split-by id
--导出数据
bin/sqoop export \
--connect jdbc:mysql://hadoop102:3306/company \
--username root \
--password 000000 \
--table staff \
--num-mappers 1 \
--export-dir /user/hive/warehouse/staff_hive \
--input-fields-terminated-by "\t"