UPDATE

description

Syntax

  1. UPDATE table_name
  2. SET assignment_list
  3. WHERE expression
  4. value:
  5. {expr | DEFAULT}
  6. assignment:
  7. col_name = value
  8. assignment_list:
  9. assignment [, assignment] ...

Parameters

  • table_name: The target table of the data to be updated. Can be in the form of ‘db_name.table_name’
  • assignment_list: The target column to be updated. Can be in the form of ‘col_name = value, col_name = value’
  • where expression: The condition to be updated is an expression that returns true or false

Note

The current UPDATE statement only supports row updates on the Unique model, and there may be data conflicts caused by concurrent updates. Currently Doris does not deal with such problems, and users are required to avoid such problems from the business side.

example

The test table is a unique model table, which contains four columns: k1, k2, v1, v2. Among them, k1, k2 are keys, v1, v2 are values, and the aggregation method is Replace.

  1. Update the v1 column that satisfies the conditions k1 =1 and k2 = 2 in the’test’ table to 1
  1. UPDATE test SET v1 = 1 WHERE k1=1 and k2=2;
  1. Increment the v1 column of the column with k1=1 in the’test’ table by 1
  1. UPDATE test SET v1 = v1+1 WHERE k1=1;

keyword

  1. UPDATE