Altering a computed column

Change or remove the expression used in a computed column.

Prerequisites

You must have DBA authority, or be the owner of the table, or have permissions to alter the table.

Context and remarks

Many.

 Alter a computed column using SQL
  1. Connect to the database.

  2. Execute an ALTER TABLE statement similar to the following to change the expression used for a computed column:

    ALTER TABLE table-name
    ALTER column-name
    SET COMPUTE ( new-expression );
  3. To convert a column to a regular (non-computed) column, execute an ALTER TABLE statement similar to the following:

    ALTER TABLE
    table-name
    ALTER column-name
    DROP COMPUTE;

Results

In the case of changing the computation for the column, the column is recalculated when this statement is executed.

In the case of a computed column being changed to be a regular (non-computed) column, existing values in the column are not changed when the statement is executed, and are not automatically updated thereafter.

Next

None.

 See also