Saturday, March 22, 2014

Updatable Views - Conditions

You can modify the data of an underlying base table through a view, as long as the following conditions are true:
·         Any modifications, including UPDATE, INSERT, and DELETE statements, must reference columns from only one base table.
·         The columns being modified in the view must directly reference the underlying data in the table columns. The columns cannot be derived in any other way as through the following:
§  An aggregate function: AVG, COUNT, SUM, MIN, MAX, GROUPING, STDEV, STDEVP, VAR, and VARP.
§  A computation. The column cannot be computed from an expression that uses other columns. Columns that are formed by using the set operators UNION, UNION ALL, CROSSJOIN, EXCEPT, and INTERSECT amount to a computation and are also not updatable.
§  The columns being modified are not affected by GROUP BY, HAVING, or DISTINCT clauses.
§  TOP is not used anywhere in the select_statement of the view together with the WITH CHECK OPTION clause.

No comments:

Post a Comment