美文网首页hive
Hive建表中ORC格式的使用

Hive建表中ORC格式的使用

作者: liuzx32 | 来源:发表于2018-11-26 14:15 被阅读8次

refer:https://blog.csdn.net/longshenlmj/article/details/51702343

#Hive建外部External表(外部表external table):

CREATE EXTERNAL TABLE `table_name`(
  `column1` string,
  `column2` string,
  `column3` string)
PARTITIONED BY (
  `proc_date` string)
ROW FORMAT SERDE 
   'org.apache.hadoop.hive.ql.io.orc.OrcSerde'
STORED AS INPUTFORMAT 
   'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'
OUTPUTFORMAT
   'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
LOCATION
  'hdfs://hdfscluster/...'
TBLPROPERTIES ( 'orc.compress'='snappy');

#

#

#添加分区并加载分区数据:

alter table table_name add partition (proc_date='${hivevar:pdate}') location '...'(不改变源数据存储位置)

alter table table_name add if not exsit partition (proc_date='${hivevar:pdate}') location 'hdfs://hdfscluster/'

load data inpath '...' into table table_name partition(proc_date='${hivevar:pdate}');(会将源数据切到hive表指定的路径下)


#删除分区:alter table table_name drop if exists partition(proc_date='${hivevar:pdate}');


#TBLPROPERTIES

实际上就是table properties,TBLPROPERTIES允许开发者定义一些自己的键值对信息。可以对TBLPROPERTIES进行查看和修改(部分可修改)。在TBLPROPERTIES中有一些预定义信息,比如last_modified_user和last_modified_time,其他的一些预定义信息包括:

TBLPROPERTIES ("comment"="table_comment")
TBLPROPERTIES ("hbase.table.name"="table_name")
TBLPROPERTIES ("immutable"="true") or ("immutable"="false")
TBLPROPERTIES ("orc.compress"="ZLIB") or ("orc.compress"="SNAPPY") or ("orc.compress"="NONE")
TBLPROPERTIES ("transactional"="true") or ("transactional"="false")
TBLPROPERTIES ("NO_AUTO_COMPACTION"="true") or ("NO_AUTO_COMPACTION"="false"), the default is "false"
TBLPROPERTIES ("compactor.mapreduce.map.memory.mb"="mapper_memory")
TBLPROPERTIES ("compactorthreshold.hive.compactor.delta.num.threshold"="threshold_num")
TBLPROPERTIES ("compactorthreshold.hive.compactor.delta.pct.threshold"="threshold_pct")
TBLPROPERTIES ("auto.purge"="true") or ("auto.purge"="false")
TBLPROPERTIES ("EXTERNAL"="TRUE")
#

#tplproperties属性参考
(1)comment:可以用来定义表的描述信息。
(2)hbase.table.name:hive通过 storage handler(暂放)将hive与各种工具联系起来,这是是使用hive接入hbase时,设置的属性(暂放)。
(3)immutable:顾名思义‘不可变的’,当表的这个属性为true时,若表中无数据时可以insert数据,但是当表已经有数据时,insert操作会失败。不可变表用来防止意外更新,避免因脚本错误导致的多次更新,而没有报错。本人实际中还没用到这个属性。
(4)orc.compress:这是orc存储格式表的一个属性,用来指定orc存储的压缩方式(暂放)。
(5) transactional,NO_AUTO_COMPACTION,compactor.mapreduce.map.memory.mb,compactorthreshold.hive.compactor.delta.num.threshold,compactorthreshold.hive.compactor.delta.pct.threshold:这5个属性与hive的事务支持有关,先不做了解。
(6)auto.purge:当设置为ture时,删除或者覆盖的数据会不经过回收站,直接被删除。配置了此属性会影响到这些操作: Drop Table, Drop Partitions, Truncate Table,Insert Overwrite。
(7)EXTERNAL:通过修改此属性可以实现内部表和外部表的转化。

#

相关文章

  • Hive建表中ORC格式的使用

    refer:https://blog.csdn.net/longshenlmj/article/details/5...

  • Hive ORC

    ORC是RCfile的优化版本 关于Hive的文件格式 TEXTFILE 默认格式,建表时不指定默认为这个格式,...

  • 大数据开发之Hive优化篇5-使用ORC文件格式优化Hive

    备注:Hive 版本 2.1.1 如果使用Hive作为大数据仓库,强烈建议主要使用ORC文件格式作为表的存储格式 ...

  • Hive ORC

    ORC是RCfile的优化版本 1. 关于hive的文件格式 TEXTFILE默认格式,建表时不指定默认为这个格式...

  • orc文件格式对常用系统的支持

    1、Hive支持 创建表时指定orc格式即可: 压缩格式有"SNAPPY"和 "ZLIB"两种,需要哪种格式指定即...

  • ORC File

    ORC 文件是在hive 0.11.0开始支持。 ORC 文件格式 相对于其他的文件格式,ORC文件格式有以下优点...

  • Metastore格式和分隔符

     Hive目前支持的数据格式包括Text File、SequenceFile、RCFile、Avro、ORC 和P...

  • hive中常用命令(建表、删表等)

    hive中常用命令(建表、删表等) 1.hive中的语句使用英文;结尾 2.进入数据库 use test_db; ...

  • ORC原理及查询优化

    Hive从0.11版本开始提供了ORC的文件格式,ORC文件不仅仅是一种列式文件存储格式,最重要的是有着很高的压缩...

  • hive中orc表sqoop导出到mysql

    环境: sqoop版本:1.4.6hive版本:2.1.1hadoop版本:2.7.3 起因: orc表导出到my...

网友评论

    本文标题:Hive建表中ORC格式的使用

    本文链接:https://www.haomeiwen.com/subject/tfkbqqtx.html