Difference between revisions of "CALCULATED Column Constraint"
Helengeorge (Talk | contribs) (→Products) |
Yvonnemilne (Talk | contribs) |
||
Line 19: | Line 19: | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | ALTER TABLE customer | + | ALTER TABLE customer; |
− | ALTER COLUMN available CALCULATED limit-balance | + | ALTER COLUMN available CALCULATED limit-balance; |
− | ALTER COLUMN limit RECALCULATE | + | ALTER COLUMN limit RECALCULATE; |
− | ALTER COLUMN balance RECALCULATE | + | ALTER COLUMN balance RECALCULATE |
</code> | </code> | ||
Latest revision as of 11:18, 22 December 2009
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