Hive實戰9---更新、刪除操作
阿新 • • 發佈:2019-01-05
1、建立表:
create table users2(id int,name string)clustered by (id) into 1 buckets stored as
orc tblproperties('transactional'='true');
2、插入資料
insert into users2(1,'ZHANGSAN'),(2,'LISI');
3、更新資料
update users2 set name='zhangsan2' where id=1;
報錯:
FAILED: SemanticException [Error 10294]: Attempt to do update or delete using transaction manager that does not support these operations.
4、更改設定:
客戶端:
set hive.support.concurrency = true;
set hive.enforce.bucketing = true ;
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.txn.manager= org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
伺服器端:
更改hive-site.xml,增加如下屬性:
<property>
<name>hive.compactor.initiator.on</name>
<value>true</value>
</property>
<property>
<name>hive.compactor.worker.threads </name>
<value>1</value>
</property>
5、退出hive客戶端,重新進入
6、執行更新操作
7、刪除操作
delete from users2 where id=1;