create table if not exists u(
id int,
name string
)
comment ''
row format delimited fields terminated by '\t'
lines terminated by '\n'
stored as textfile; //存储格式,默认是使用文本文件(textfile)
hive几种文件存储格式
1.**textfile:**默认格式,普通文本文件,数据不压缩,磁盘开销大,分析开销大。
2.**sequencefile:**hive提供的一种二进制存储格式,可以切割,天生压缩
1.不可以直接使用load加载
2.可以使用insert into table sf select name,score from xx;
3.占内存比textfile大,压缩算法本身占一定空间
4.查询速度比textfile格式快。
3.**rcfile:**hive提供的一种行列混合存储方式,该方式将会把相近的行和列数据放在一块,
存储较耗时,查询效率高,也天生压缩。
1.不能用load加载。
2.比sequencefile占空间稍微小一些。
3.查询速度比textfile格式快。
//压缩
set hive.exec.compress.output=true 使用默认压缩格式
set mapred.output.compression.codec=org.apache.hadoop.id.compress.GZipCodec改变压缩格式
<