How to delete and update a record in Hive

As of Hive version 0.14.0: INSERT…VALUES, UPDATE, and DELETE are now available with full ACID support.

INSERT … VALUES Syntax:

INSERT INTO TABLE tablename [PARTITION (partcol1[=val1], partcol2[=val2] ...)] VALUES values_row [, values_row ...]

Where values_row is:
( value [, value …] )
where a value is either null or any valid SQL literal

UPDATE Syntax:

UPDATE tablename SET column = value [, column = value ...] [WHERE expression]

DELETE Syntax:

DELETE FROM tablename [WHERE expression]

Additionally, from the Hive Transactions doc:

If a table is to be used in ACID writes (insert, update, delete) then the table property “transactional” must be set on that table, starting with Hive 0.14.0. Without this value, inserts will be done in the old style; updates and deletes will be prohibited.

Hive DML reference:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML

Hive Transactions reference:

https://cwiki.apache.org/confluence/display/Hive/Hive+Transactions

Leave a Comment