1. 数据文件
数据文件如下,txt文件,并且分隔符为’,'。
2. Hive建表
使用row format delimited fields terminated by ","
指定数据分隔符。
create table student(id int comment "ID",
name string comment "姓名",
age int comment "年龄",
haibt string comment "爱好"
)comment "学生表" row format delimited fields terminated by ",";
3. 上传txt文件至HDFS
执行命令。这里需要注意自己的hive表的所在路径。
hdfs dfs -put student.txt /hive/warehouse/test.db/student/
然后可以执行select 命令查看表数据是否添加。