Modifying Data
The UPDATE command changes column values. A quick look at some of our
albums with the following query shows three albums not on 'cd':
isql=>SELECT * FROM music.albums WHERE medium <> 'cd';Return
____________________________________________________________________________________
| |
| |
| select * from music.albums where medium |
| 'cd'; |
| -----------+----------------------------------------+------+------------+-- |
| ALBUMCODE |ALBUMTITLE |MEDIUM|ALBUMCOST |RE |
| -----------+----------------------------------------+------+------------+-- |
| 2002|Famous Bel Canto Arias |ca | 22.00|dg |
| 2005|Nielsen Symphonies 4 & 5 |ca | 13.00|lo |
| 2006|Lenontyne Price: a Christmas Offering |ca | 13.00|lo |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| --------------------------------------------------------------------------- |
| Number of rows selected is 3 |
| U[p], d[own], l[eft], r[ight], t[op], b[ottom], pr[int] <n>, or e[nd] > e |
| |
____________________________________________________________________________________
Figure 6-11. Result of the Query
To change the column values of these albums to 'lp' for 'Long Play'
records, use the following:
isql=>UPDATE music.albums SET medium = 'lp' WHERE medium = 'ca';Return
Number of rows processed is 3
isql=>COMMIT WORK; Return
isql=>SELECT * FROM music.albums WHERE medium <>'cd';Return
____________________________________________________________________________________
| |
| |
| select * from music.albums where medium <> 'cd'; |
| ALBUMCODE |ALBUMTITLE |MEDIUM|ALBUMCOST |RE |
| -----------+----------------------------------------+------+------------+-- |
| 2002|Famous Bel Canto Arias |lp | 22.00|dg |
| 2005|Nielsen Symphonies 4 & 5 |lp | 13.00|lo |
| 2006|Lenontyne Price: a Christmas Offering |lp | 13.00|lo |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| --------------------------------------------------------------------------- |
| Number of rows selected is 3 |
| U[p], d[own], l[eft], r[ight], t[op], b[ottom], pr[int] <n>, or e[nd] > e |
| |
____________________________________________________________________________________
Figure 6-12. Result of Modifying Data