Hive初级使用

创建表student,创建文件student.txt ,文件里面有学生数据行数据之间的列用制表(tab)符分割。
需求:把文件中的数据导入到student表中。

创建student表

创建以格式化行以制表符(tab)分割的字段表
create table student(id int, name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';

创建student.txt文件并新增数据

touch /opt/datas/student.txt


Hive初级使用Hive初级使用

把文本数据导入到student表中

命令:load data local inpath '/opt/datas/student.txt'into table student ;

Hive初级使用

查看结果

  • select * from student ;

    Hive初级使用
  • select id from student ; 就会运行MapReduce 。说明hive进行了优化

    Hive初级使用