Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements >

UPDATE

Use the UPDATE statement to change the values in one or more columns of one or more existing rows in a table or view.

With Dynamic Server, you can also use this statement to change the values in one or more elements in an ESQL/C collection variable.

Syntax

Read syntax diagramSkip visual syntax diagram>>-UPDATE------------------------------------------------------->
 
                                                                                        (4)
>--+-+---------------------------------------------+--| Table Options |--| SET Clause |-------| Where Options |-+-><
   | |  (1)    (2)                            (3)  |                                                            |
   | '---------------| Optimizer Directives |------'                                                            |
   |                              (5)                  (4)                                                      |
   '-| Collection-Derived Table |-------| SET Clause |-------+-----------------------------------------+--------'
                                                             |  (6)    (7)                             |
                                                             '---------------WHERE CURRENT OFcursor_id-'
 
Table Options:
 
|--+-table-----------------------------+------------------------|
   +-view------------------------------+
   +-synonym---------------------------+
   |  (1)    (2)                       |
   '---------------ONLY--+-(table )--+-'
                         '-(synonym)-'
 
Where Options:
 
|--+-+--------------------------------+--+---------------------------+-+--|
   | |                           (8)  |  |                      (9)  | |
   | '-| Subset of FROM Clause |------'  '-WHERE--| Condition |------' |
   |  (6)    (7)                                                       |
   '---------------WHERE CURRENT OFcursor_id---------------------------'
 
Notes:
  1. Informix extension
  2. Dynamic Server only
  3. See page Optimizer Directives
  4. See page SET Clause
  5. See page Collection-Derived Table
  6. ESQL/C only
  7. Stored Procedure Language only
  8. See page Subset of FROM Clause
  9. See page Condition

Element Description Restrictions Syntax
cursor_id Name of a cursor whose current row is to be updated You cannot update a row that includes aggregates Identifier,
p. Identifier
synonym, table, view Synonym, table, or view that contains the rows to be updated The synonym and the table or view to which it points must exist Database Object Name, p. Database Object Name

Usage

Use the UPDATE statement to update any of the following types of objects:

For information on how to update elements of a collection variable, see Collection-Derived Table. Sections that follow in this description of the UPDATE statement describe how to update a row in a table.

You must either own the table or have the Update privilege for the table; see GRANT. To update data in a view, you must have the Update privilege, and the view must meet the requirements that are explained in Updating Rows Through a View.

The cursor (as defined in the SELECT ... FOR UPDATE portion of a DECLARE statement) can contain only column names. If you omit the WHERE clause, all rows of the target table are updated.

If you are using effective checking and the checking mode is set to IMMEDIATE, all specified constraints are checked at the end of each UPDATE statement. If the checking mode is set to DEFERRED, all specified constraints are not checked until the transaction is committed.

In Extended Parallel Server, if UPDATE is constructed in such a way that a single row might be updated more than once, the database server returns an error. If the new value is the same in every update, however, the database server allows the update to take place without reporting an error.

In DB-Access, if you omit the WHERE clause and are in interactive mode, DB–Access does not run the UPDATE statement until you confirm that you want to change all rows. If the statement is in a command file, however, and you are running at the command line, the statement executes immediately.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]