Home Oracle Commands

UPDATE Statement

Modify the values stored in a table.

Syntax:

   UPDATE [hint] [schema.]table [@dblink] [alias]
      SET col_expr(s)
        [WHERE condition]
           [ RETURNING (expr,...) INTO (data_item,...) ]

   UPDATE [hint] [schema.]table [[SUB]PARTITION (partition)] [alias]
      SET col_expr(s)
        [WHERE condition]
           [ RETURNING (expr,...) INTO (data_item,...) ]

   UPDATE [hint] [schema.]view [@dblink] [alias]
      SET col_expr(s)
        [WHERE condition]
           [ RETURNING (expr,...) INTO (data_item,...) ]

   UPDATE [hint] [schema.]materialized_view [@dblink] [alias]
      SET col_expr(s)
        [WHERE condition]
           [ RETURNING (expr,...) INTO (data_item,...) ]

   UPDATE [hint] (subquery)
     WITH {READ ONLY | CHECK OPTION [CONSTRAINT constraint]} 
      SET col_expr(s)
        [WHERE condition]
           [ RETURNING (expr,...) INTO (data_item,...) ]

   UPDATE [hint] TABLE (table_collection_expression) [(+)] 
      SET col_expr(s)
        [WHERE condition]
           [ RETURNING (expr,...) INTO (data_item,...) ]

col_expr:
   column = expression
   column = (subquery)
   column = DEFAULT
   (column, column,...) = (subquery)
   VALUE (table_alias) = expression
   VALUE (table_alias) = (subquery)

  To update multiple columns, separate col_expr with commas.

The terms "snapshot" and "materialized view" are synonymous.
The syntax above can also be modified to UPDATE [hint] ONLY (expression). Specify ONLY syntax if the view in the UPDATE clause belongs to a hierarchy and you do not want to update rows from any of its subviews.

table_collection_expression can be a subquery, a column, a function, or a collection constructor, it must return a collection value (that is, a value whose type is nested table or varray). This allows you to update rows in one table based on rows from another table.

"If the shoe fits, buy it." - Imelda Marcos

Related Commands:

DELETE
EXPLAIN PLAN
INSERT

SELECT

TRUNCATE

Related Views:

  DBA_SNAPSHOTS        ALL_SNAPSHOTS        USER_SNAPSHOTS 
  DBA_ALL_TABLES       ALL_ALL_TABLES       USER_ALL_TABLES
  DBA_TABLES           ALL_TABLES           USER_TABLES         TAB
  DBA_VIEWS            ALL_VIEWS            USER_VIEWS
                                                                DICTIONARY
                                                                DICT_COLUMNS



Back to the Top

Simon Sheppard
SS64.com