默认存储格式textfile
textfile:普通的文本文件存储,不压缩
sequencefile:hive为用户提供的二进制存储,本身就压缩,不能使用load的方式加载数据
rcfile:hive提供的行列混合存储,hive在该格式下,会尽量将附近的行和列得块存储到一起,仍然是压缩格式,查询效率比较高
orc:orf是rcfile的升级版
首先是默认的:textfile
create table if not exists text2(
uid int,
uname string,
sex string,
age int,
step string
)
row format delimited
fields terminated by ','
stored as textfile
;
加载数据:
load data local inpath '/root/students.txt' into table text2;

然后创建存储格式为sequencefile的
create table if not exists seq1(
uid int,
uname string,
sex string,
age int,
step string
)
row format delimited
fields terminated by ','
stored as sequencefile
;
加载数据:
load data local inpath '/root/students.txt' into table seq1;
注意,这种方式不能load加载数据的!
提示:
需要用insert into的方式来加载数据:
insert into seq1
select * from text2;

结果为: 
然后是rcfile格式的:
create table if not exists rc1(
uid int,
uname string,
sex string,
age int,
step string
)
row format delimited
fields terminated by ','
stored as rcfile
;
加载数据的时候也是不能load数据
不可以使用这种方式加载数据
load data local inpath '/root/students.txt' into table rc1;#报错!!!
应该使用insert into的方式加载数据
insert into rc1
select * from text2;

本文详细介绍了Hive中四种不同的存储格式:textfile、sequencefile、rcfile和orc。每种格式的特点、适用场景及如何在Hive中创建对应格式的表进行了深入探讨。文章还解释了不同格式在数据加载过程中的限制,例如sequencefile和rcfile不支持使用load方式加载数据,而需采用insert into方式。
2489

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



