| < Day Day Up > |
|
The Update statement changes the values for one or more columns in the table. Here is its syntax:
Update <table>
Set <column> = <value> [, <column> = <value>]…
[Where <expression>]
Where <table> is the name of the table that you wish to update, <column> is the name of the column in the table, <value> is the new value that will be stored in the column, and <expression> is true for all the rows that should be updated.
The Update statement provides a method that permits you to change the value of one or more columns in the table. You must explicitly specify each column that you wish to change, along with the column’s new value. Also remember that the Update statement can include a Where clause. This Where clause is identical to the one you use in the Select statement and it works just like you would expect. Only the rows that match the expression in the Where clause will be updated—the other rows will remain unchanged.
Tip | Limit Your Exposure |
In this example, the Where clause is used to identify all the rows that contain a Null value in the DateUpdated field. The DateUpdated column is then set to ‘01-Jan-2003’.
Update Customers
Set DateUpdated = ’01-Jan-2003’
Where DateUpdated Is Null
| < Day Day Up > |
|