UPDATE changes values stored in user-created tables.


UPDATE table_name AS alias SET column_name = expr , WHERE condition
Field Use
UPDATE table_name The table whose values you want to update.
alias Only permit references to table_name as alias.
SET col_ref = expr Assign the value of expr to col_ref.
WHERE condition Only update rows which evaluate to true for condition.


UPDATE cannot currently…


CREATE TABLE update_me (a int, b text);
INSERT INTO update_me VALUES (1, 'hello'), (2, 'goodbye');
UPDATE update_me SET a = a + 2 WHERE b = 'hello';
SELECT * FROM update_me;
 a |    b
 3 | hello
 2 | goodbye
UPDATE update_me SET b = 'aloha';
SELECT * FROM update_me;
 a |   b
 2 | aloha
 3 | aloha
Back to top ↑