Modifying table data in a SQL database with a well-created view

Source: Internet
Author: User

You can modify the data of the underlying base table through the view as long as the following conditions are true:

1. Any modifications (including UPDATE, INSERT, and DELETE statements) can reference only one column of a base table.

2. Columns that are modified in the view must refer directly to the underlying data in the table column. These columns cannot be derived in any other way, as in the following ways:
1) Aggregate functions: AVG, COUNT, SUM, MIN, MAX, GROUPING, STDEV, STDEVP, VAR, and VARP.
2) calculation. The column cannot be evaluated from an expression that uses a different column. Columns formed using the SET Operator Union, UNION ALL, CROSSJOIN, EXCEPT, and INTERSECT are counted in the calculation and cannot be updated.

3. The modified column is not affected by the GROUP by, having, or DISTINCT clauses.

4. TOP is not used anywhere in the view's select_statement with the CHECK OPTION clause.

The above restrictions apply to any subquery in the view's FROM clause as if it were applied to the view itself. Typically, the database engine must be able to explicitly track modifications from a view definition to a base table

Modifying table data in a SQL database with a well-created view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.