Update Command

From rbachwiki
Jump to navigation Jump to search

Update Command

Used to change the contents of existing rows

  • The UPDATE clause identifies the table containing the records to be changed.
  • The SET clause identifies the columns to be changed and the new values to be assigned to these columns.
  • The optional WHERE clause identifies the exact records to be changed by the UPDATE command. If the WHERE clause is omitted, the column specified in the SET clause is updated for all records in the table.
UPDATE acctmanager
SET amedate = '01-AUG-09'
WHERE amid = 'J500';

Change multiple records that match a criteria

All records that have NE and NW will be changed to W

UPDATE acctmanager 
SET region = 'W'
WHERE region IN ('NE', 'NW')

Update Multiple Columns =

UPDATE acctmanager
SET amedate = '10-OCT-09',
    region = 'S'
WHERE amid = 'J500'

Using Substituion Variables

A substitution variable in an SQL command instructs Oracle 11g to substitute a value in place of the variable at the time the command is actually executed. To include a substitution variable in an SQL command, simply enter an ampersand (&) followed by the name used for the variable.

UPDATE customers
SET region = '&Region'
WHERE state ='&State';

This will pop up a dialog box prompting you to enter the Region and State

Back To Top- Home - Category