CALCULATED Column Constraint

From Recital Documentation Wiki
Revision as of 16:21, 9 December 2009 by Helengeorge (Talk | contribs)

Jump to: navigation, search

Purpose

Column constraint to calculate the value of a column


Syntax

CALCULATED <expr>


See Also

ALTER TABLE, CONSTRAINTS, CREATE TABLE


Description

A constraint is used to define rules that help to provide data integrity. Column constraints are specific to the column name specified. You must have ALTER privilege on the table. The table will be locked for EXCLUSIVE use during the operation.

The CALCULATED column constraint is used to calculate the value of a column whenever it is accessed. The <expr> specified must evaluate to the same data type as the target column. Specifying the CALCULATED column constraint causes the column to be read only. If the <expr> is based on other columns from the same table, these columns must have the RECALCULATE column constraint set, so that any changes to their values cause calculated fields to be recalculated.


Example

ALTER TABLE customer
ALTER COLUMN available CALCULATED limit-balance
ALTER COLUMN limit RECALCULATE
ALTER COLUMN balance RECALCULATE;


Products

Recital, Recital Server