1、orc存储格式的表的创建
create table if not exists test(
name string,
num double,
born timestamp
)
row format delimited
fields terminated by ‘\t’
stored as orc
tblproperties(“orc.compress” = “snappy”);
压缩格式有两种:snappy和zlib
2、数据的插入
①单条插入或者从其它表插入
insert into test(name,num,born) values(’’, ,’’);
insert into test select * from other_table;
复制表结构:
create table A.test like B.test[ row format delimited fields terminated by ‘|’ ]
复制表结构及数据:(先复制表结构)
insert into test select * from B.test;
②从txt文件插入:(test表以orc 为存储格式,other_table表以txt为存储格式);
存储格式为 ORC 的 hive 表,不能直接 load 文件,因为 ORC 格式的数据是有压缩操作的,并不是常规的格式。
可以先将txt文件load到hive表other_table中(还可以直接put到hdfs上的hive表),再使用①中的第二条语句进行操作。