簡體   English   中英

在Hive中更新和刪除

[英]Update and delete in Hive

我正在經歷“ Programming Hive”,發現了以下內容。

Hive offers no support for rowlevel
inserts, updates, and deletes. Hive doesn’t support transactions.

但是在CDH5上,我可以向表中添加一行。 但是更新和刪除將錯誤拋出為“語義錯誤”。 我讀到可以在蜂巢上設置ACID屬性,但是它不起作用。

問題:我們可以更新和刪除配置單元中的記錄嗎?

Hive不適用於OLTP,但現在它支持ACID操作,您必須為其更改一些配置。 要嘗試,請執行以下操作:

    set hive.support.concurrency = true;
    set hive.enforce.bucketing = true;
    set hive.exec.dynamic.partition=true;
    set hive.exec.dynamic.partition.mode = nonstrict;

ACID交易(插入,更新和刪除)

  • 步驟1 create table testTableNew(id int ,name string ) clustered by (id) into 2 buckets stored as orc TBLPROPERTIES('transactional'='true');

  • 步驟2 insert into table testTableNew values (1,'row1'),(2,'row2'),(3,'row3');

  • 步驟3 update testTableNew set name = 'updateRow2' where id = 2;

  • 步驟4 delete from testTableNew where id = 1;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM