hadoop - 在Hive中更新和删除

标签 hadoop hive

我经过“Programming Hive”编程后发现以下内容。

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

但是在CDH5上,我可以在表中添加一行。但是更新和删除将错误抛出为“语义错误”。我读到ACID属性可以在配置单元上设置,但不能正常工作。

Question : Can we update and delete a record in hive?

最佳答案

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;
  • 关于hadoop - 在Hive中更新和删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37802264/

    相关文章:

    hadoop - Hive 查询中的分配

    java - 如何为 KeyValueTextInputFormat 使用整数输入键

    sql - HiveQL - 大数据的高效 geoip 发现

    sql - 在现有配置单元表上添加分区

    hadoop - 是否可以保存 Hive UDTF 生成的值?

    sql - NVL 在查询中使用案例

    hadoop - 使用hbase中已有的zookeeper

    hadoop - 在 Hadoop 中使用外部 Web 服务数据

    java - 处理 Hadoop 中 reduce 步骤的大输出值

    hadoop - 将 Sqoop 数据从 HDFS 迁移到 Hive