在Hive中創建xd_phy_course數據表,其數據表結構如下表所示。使用Sqoop工具將MySQL中xiandian數據庫下xd_phy_course表導入到Hive數據倉庫中的xd_phy_course表中。
1,先創建一個hive表,
create table h2 (stname string,stID int,class string,opt_cour string) row format delimited fields terminated by '\t' lines terminated by '\n';
2,用sqoop工具將mysql中的數據轉移到hive表中,這裏創建mysql表在mysql表
sqoop import --connect jdbc:mysql://localhost:3306/xiandian --username root --password bigdata --table m1 --hive-import --hive-overwrite --hive-table h2 -m 1 --fields-terminated-by '\t' --lines-terminated-by '\n'