The UPDATE statement is used to update the rows in a table.
Basic syntax for the UPDATE statement:
UPDATE table_name
SET column_name = value [, column_name = value]...
[ WHERE condition ];
Where, column_name is the column to be updated. The value following the equal sign (=) is the target value to be updated, which must conform to the column type. The WHERE clause specifies the conditions that rows must meet to be updated. The absence of the WHERE clause means that all the records in the corresponding column are updated.
Example: Updating all records
obclient> update t_insert set value=value+1 ;
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0
Note
When you execute an Update statement that involves more than one hundred thousand records without using the WHERE clause, a large transaction is generated. If the transaction is too large, the update may fail. Therefore, be sure to control the size of a transaction during an update.
Example: Updating some records and enable error reporting upon a constraint violation
obclient> create unique index uk_name on t_insert(name);
Query OK, 0 rows affected (1.99 sec)
obclient> update t_insert set name='US' where id=3;
ORA-00001: unique constraint 'US' for key 'UK_NAME' violated