默认存储格式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;