-
首先创建hive表:
--首先创建hive表 create database db_7; use db_7; create table t_student( id int, name string, sex string, age int, dept string ) row format delimited fields terminated by ',' ;
-
hdfs dfs -put 方式(Linux终端上操作,实现hive表映射文件)
-- 方式一:使用Linux终端将Linux文件上传到HDFS中的Hive表目录,实现hive表映射 hdfs dfs -put /root/04_students.txt /user/hive/warehouse/db_7.db/t_student
-
load data 方式(SQL上操作,实现文件插入hive表)
-- 方式二:把local本地系统linux上的文件插入到hive表中 -- 追加效果 load data local inpath '/root/04_students.txt' into table t_student; -- 覆盖效果 load data local inpath '/root/04_students.txt' overwrite into table t_student; -- 方式三:把hdfs上的文件插入到hive表中 load data inpath '/hivedata/66666666_students.txt' into table t_student;