UPDATE command is used to change
or modify data values in a table.
The verb update in SQL is used to
either update:
Ø
All the rows
from a table
OR
Ø
A select set
of rows from a table
Updating
All Rows
The UPDATE statement
updates columns in the existing table’s rows with new values. The SET clause
indicates which column data should be modified and the new values that they
should hold. The WHERE clause, if given, specifies which rows should be
updated. Otherwise, all table rows are updated.
Syntax:
UPDATE
SET = , =
;
Exmaple:
Update
the address details by changing its city name to Bombay
UPDATE
ADDR_DTLS SET City =’Bombay’;
Output:
12 rows
updated.
Updating Records
Conditionally
Syntax
:
UPDATE
SET =
, =
WHERE Condition;
Example :
Update
the branch details by changing the Vile Parle (HO) to head office.
UPDATE
BRANCH_MSTR SET NAME.=’Head
Office’ WHERE NAME = ‘Vile Parle (HO)’;
Output:
1
row updated.
No comments:
Post a Comment