Updating Values

The UPDATE statement is used to change the values in an existing record.

The UPDATE statement has this general format:

Format of SQL UPDATE statement

Additional information

UPDATE tablename
   SET
     colName1=value1  ,colName2=value2 ...     <— can provide a value for all
   WHERE                                       attributes or just some
     colNamei  someOperator  valuei   ...      <— can repeat this line,
;                                              separated by AND or OR

Here is an example of the use of the UPDATE statement:

Example of SQL UPDATE statement

Additional information

UPDATE Person
  SET  age = 25, lives_in = 'USA'   Robert celebrated his birthday by moving to
  WHERE name='Robert Bellamy' ;     the USA.

This statement will start to populate (fill in with data) the Person table that we saw earlier in the chapter. The values are inserted into the record in the order in which the attributes are named.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.111.197