Hive擴展功能(九)--Hive的行級更新操作(Update)


軟件環境:

linux系統: CentOS6.7
Hadoop版本: 2.6.5
zookeeper版本: 3.4.8

##主機配置: ####一共m1, m2, m3這三部機, 每部主機的用戶名都為centos ``` 192.168.179.201: m1 192.168.179.202: m2 192.168.179.203: m3

m1: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Master, Worker
m2: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Worker
m3: Zookeeper, DataNode, NodeManager, Worker







####資料:

官方資料:
Update資料 <=> https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML
Join資料 <=> https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Joins

網上參考資料:
Update資料 <=> http://www.aboutyun.com/thread-12155-1-1.html




---
<br>
##一.為Hive配置Update功能
####1.編輯hive-site.xml文件:
hive.optimize.sort.dynamic.partition false hive.support.concurrency true hive.enforce.bucketing true hive.exec.dynamic.partition.mode nonstrict hive.txn.manager org.apache.hadoop.hive.ql.lockmgr.DbTxnManager hive.compactor.initiator.on true hive.compactor.worker.threads 1 hive.in.test true ```

##二.Update語法 ####1.創表語句 Hive對使用Update功能的表有特定的語法要求, 語法要求如下: (1)要執行Update的表中, 建表時必須帶有buckets(分桶)屬性 (2)要執行Update的表中, 需要指定格式,其余格式目前贊不支持, 如:parquet格式, 目前只支持ORCFileformat和AcidOutputFormat (3)要執行Update的表中, 建表時必須指定參數('transactional' = true); 舉例: ``` create table student (id bigint,name string) clustered by (name) into 2 buckets stored as orc TBLPROPERTIES('transactional'='true'); ```

2.更新語句:

update student set id='444' where name='tom';





免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM