Versions available for this page: CUBRID 8.2.1 | CUBRID 8.3.0 | CUBRID 8.3.1 | CUBRID 8.4.0 | CUBRID 8.4.1 | CUBRID 8.4.3 | CUBRID 9.0.0 |
You can update the column value of a record saved in the target table to a new one by using the UPDATE statement. Specify the name of the column to update and a new value in the SET clause, and specify the condition to be used to extract the record to be updated in the WHERE Clause. You can also specify the number of records to be updated in the LIMIT clause.
UPDATE table_name SET column_name = {expr | DEFAULT} [, column_name = {expr | DEFAULT]...]
[WHERE search_condition]
[LIMIT row_count]
One column can be updated only once in the same UPDATE statement.
--creating a new table having all records copied from a_tbl1
CREATE TABLE a_tbl5 AS SELECT * FROM a_tbl1;
SELECT * FROM a_tbl5 WHERE name IS NULL;
;xr
=== <Result of SELECT Command in Line 1> ===
id name phone
=========================================================
NULL NULL '000-0000'
4 NULL '000-0000'
5 NULL '000-0000'
7 NULL '777-7777'
4 rows selected.
UPDATE a_tbl5 SET name='yyy', phone='999-9999' WHERE name IS NULL LIMIT 3;
SELECT * FROM a_tbl5;
;xr
=== <Result of SELECT Command in Line 1> ===
id name phone
=========================================================
NULL 'yyy' '999-9999'
1 'aaa' '000-0000'
2 'bbb' '000-0000'
3 'ccc' '333-3333'
4 'yyy' '999-9999'
5 'yyy' '999-9999'
6 'eee' '000-0000'
7 NULL '777-7777'
8 rows selected.