Insert view conditions:
1. if a view is generated based on a basic table, this is called a non-join view. All non-join views can be updated, that is, they can be performed on the view, insert, update, delete operation.
2. for a connection view, follow the basic update rules. now I only want to explain the insert criterion: the insert statement cannot explicitly or implicitly reference any non-code reserved fields in the base table, if the with check option clause is used in the defined view, the insert operation cannot be performed on The View.
Note: The non-code reserved table is interpreted as follows:
In Dept, dept_no indicates the master code, and in EMP, emp_no indicates the master code.
Create a connection View:
Create view emp_dept
Select EMP. emp_no, EMP. emp_name, EMP. dept_no, Dept. Name
From EMP, Dept
Where EMP. dept_no = Dept. dept_no
In this view, emp_no still acts as the primary code, so EMP retains the table for the code, and dept_no in dept is not the primary code, so it retains the table for the non-code.
Insert data to the view after joining multiple tables. We recommend that you use an alternative trigger.
Create trigger [Trigger name]
On [view name]
Instead of insert
As
Begin
-- Declare variables;
-- Find the data of all columns from the inserted Table and assign them to declared variables respectively;
-- Use the above data to insert data to the first table
-- Use the above data to insert data to the second table
End
In addition, the user_updatable_columns table can be used to query whether the table or view can be updated.