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

ALTER TABLE

Use the ALTER TABLE statement to modify the definition of an existing table.

Syntax

Read syntax diagramSkip visual syntax diagram>>-ALTER TABLE--+-table---+------------------------------------->
                '-synonym-'
 
                             (1)
>--+-| Basic Table Options |-------+---------------------------><
   |                          (2)  |
   '-| Logging TYPE Options |------'
 
Notes:
  1. See page Basic Table Options
  2. See page Logging TYPE Options
Element Description Restrictions Syntax
synonym Synonym for the table to be altered Synonym and its table must exist; USETABLENAME not set Database Object Name, p. Database Object Name
table Name of table to be altered Must exist in current database Database Object Name, p. Database Object Name

Usage

In Dynamic Server, the database server performs the actions in the ALTER TABLE statement in the order that you specify. If any action fails, the entire operation is cancelled.

Altering a table on which a view depends might invalidate the view.

Warning:
The clauses available with this statement have varying performance implications. Before you undertake alter operations, check corresponding sections in your IBM Informix Performance Guide to review effects and strategies.

You cannot alter a temporary table. You also cannot alter a violations or diagnostics table. In addition, you cannot add, drop, or modify a column if the table that contains the column has a violation table or a diagnostics table associated with it. If the USETABLENAME environment variable is set, you cannot specify a synonym for the table in the ALTER TABLE statement.

In Extended Parallel Server, if a table has range fragmentation, only the Logging TYPE options and LOCK MODE clause are valid. All other ALTER TABLE options return an error.

For a RAW or (in Extended Parallel Server) a STATIC table, the Logging TYPE options are the only part of the ALTER TABLE statement that you can use.

To use ALTER TABLE, you must meet one of the following conditions:

Basic Table Options

The Basic Table Options segment of ALTER TABLE has the following syntax.

Read syntax diagramSkip visual syntax diagramBasic Table Options:
 
     .-,-------------------------------------------.
     V                  (1)                        |
|--+---+-| ADD Clause |--------------------------+-+-+----------|
   |   |                           (2)           |   |
   |   +-| ADD CONSTRAINT Clause |---------------+   |
   |   |                   (3)                   |   |
   |   +-| MODIFY Clause |-----------------------+   |
   |   |                            (4)          |   |
   |   +-| DROP CONSTRAINT Clause |--------------+   |
   |   |                 (5)                     |   |
   |   +-| DROP Clause |-------------------------+   |
   |   |  (6)                               (7)  |   |
   |   +--------| MODIFY NEXT SIZE Clause |------+   |
   |   |  (6)                        (8)         |   |
   |   +--------| LOCK MODE Clause |-------------+   |
   |   |  (9)                  (10)              |   |
   |   '--------| PUT Clause |-------------------'   |
   |  (9)                                            |
   '--------+-+-ADD--+--+-CRCOLS-+-------------+-----'
            | '-DROP-'  '-ROWIDS-'             |
            |  (9)                       (11)  |
            '--------| ADD TYPE Clause |-------'
 

Notes:
  1. See page ADD Clause
  2. See page ADD CONSTRAINT Clause
  3. See page MODIFY Clause (IDS)
  4. See page DROP CONSTRAINT Clause
  5. See page DROP Clause
  6. Use path once
  7. See page MODIFY NEXT SIZE Clause
  8. See page LOCK MODE Clause
  9. Dynamic Server only
  10. See page PUT Clause (IDS)
  11. See page ADD TYPE Clause (IDS)

You can use the Basic Table Options segment to modify the schema of a table by adding, modifying, or dropping columns and constraints, or changing the extent size or locking granularity of a table. The database server performs alterations in the order that you specify. If any of the actions fails, the entire operation is cancelled.

With Dynamic Server, you can also associate a table with a named ROW type or specify a new storage space to store large-object data. You can also add or drop rowid columns and shadow columns for Enterprise Replication. You cannot, however, specify these options in conjunction with any other alterations.

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