Hive中创建orc表,插入orc表

1 创建orc表

CREATE EXTERNAL TABLE foo (
     columnA string,
     columnB string
) PARTITIONED BY (date string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY "\t"
STORED AS ORC
LOCATION '/path/to/hive/tables/foo';
TBLPROPERTIES ('orc.compress'='SNAPPY');

或者(上面的语句“STORED AS ORC”执行后,再查看建表语句,会发现已自动把INPUTFORMAT、OUTPUTFORMAT 补全,如下所示:)

CREATE EXTERNAL TABLE foo (
     columnA string,
     columnB string
) PARTITIONED BY (date string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY "\t"
STORED AS INPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' 
OUTPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
LOCATION '/path/to/hive/tables/foo';
TBLPROPERTIES ('orc.compress'='SNAPPY');

2

当使用insert语句往lzo表里插入数据时,需要加入下面的参数:

    set hive.default.fileformat=Orc;

---------

要把

SET hive.exec.compress.output=true;
SET mapred.output.compression.codec=com.hadoop.compression.lzo.LzopCodec;

去掉

你可能感兴趣的:(Hive)