UPDATE (DML)

Summary

The UPDATE statement changes existing rows and columns of data in a table.

Syntax

UPDATE <schema_name.table_name> SET column_name = new_value[, column_name2..n = new_value2..n] [WHERE];

Examples

/* Example 1: UPDATE one column for all rows in a table */
UPDATE delta.test_table SET col1 = 'We are all the same.';
 
/* Example 2: UPDATE three columns for all rows in a table */
UPDATE delta.test_table SET col1 = 'We are all the same.', col2 = 123, col3 = 42;
 
/* Example 3: UPDATE using WHERE */
UPDATE delta.test_table SET col1 = 'We are all the same.' WHERE col1 = 'We were once different';
 
/* Example 4: UPDATE a column for all rows in a table using SELECT. Note: the SELECT should only return a single row. */
UPDATE delta.test_table SET col1 = (SELECT string1 FROM AllTypes() WHERE string1 = 'abc123');