-
首先创建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;
本文介绍了如何在Hive中创建数据库和表,然后通过`hdfs dfs -put`命令将Linux文件上传至HDFS并与Hive表关联。此外,还详细展示了使用`load data`命令从本地Linux系统和HDFS加载文件到Hive表的方法,包括追加和覆盖两种模式。这些步骤对于大数据处理中的数据导入至关重要。

被折叠的 条评论
为什么被折叠?



