Updated on 2024-10-25 GMT+08:00

UPDATE

Syntax

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

Description

This statement is used to update table data based on conditions.

Remarks

  • Only the transaction table in ORC format is supported, and the table cannot be an external table.
  • The syntax set (column_name1,column_name2, ...) = (value1,value2, ...) is not supported.

Example

-- Create a transaction table.
create table upd_tb(col1 int,col2 string)  with (format='orc',transactional=true);

--Insert data.
insert into upd_tb values (3,'A'),(4,'B');

-- Change the value of col1 = 4.
update upd_tb set col1=5 where col1=4;

-- The col1=4 record is modified.
select * from upd_tb; -- 
 col1 | col2 
------|------
    5 | B    
    3 | A