UPDATE

Documentation

Home » Documentation » Using VoltDB

UPDATE

UPDATE — Updates the values within the specified columns and rows of the database.

Synopsis

UPDATE table-name SET column-name = value-expression [, ...]
[WHERE [NOT] boolean-expression [ {AND | OR} [NOT] boolean-expression]...]

Description

The UPDATE statement changes the values of columns within the specified records. The following limitations are important to note when using the UPDATE statement with VoltDB:

  • VoltDB supports the following arithmetic operators in expressions: addition (+), subtraction (-), multiplication (*), and division (*).

  • The WHERE expression supports the boolean operators: equals (=), not equals (!= or <>), greater than (>), less than (<), greater than or equal to (>=), less than or equal to (<=), IS NULL, AND, OR, and NOT. Note, however, although OR is supported syntactically, VoltDB does not optimize these operations and use of OR may impact the performance of your queries.

Examples

The following example changes the ADDRESS column of the EMPLOYEE record with an employee ID of 145303:

UPDATE employee 
    SET address = '49 Lavender Sweep' 
    WHERE employee_id = 145303;

The following example increases the starting price by 25% for all ITEM records with a category ID of 7:

UPDATE item SET startprice = startprice * 1.25 WHERE categoryid = 7;