在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'