Is there any way to insert data into multiple tables throug开发者_StackOverflowh a view in mysql?
The MySQL Reference Manual says this about updatable views:
Some views are updatable. That is, you can use them in statements such as
UPDATE
,DELETE
, orINSERT
to update the contents of the underlying table. For a view to be updatable, there must be a one-to-one relationship between the rows in the view and the rows in the underlying table. There are also certain other constructs that make a view nonupdatable.The
WITH CHECK OPTION
clause can be given for an updatable view to prevent inserts or updates to rows except those for which theWHERE
clause in the select_statement is true. TheWITH CHECK OPTION
clause was implemented in MySQL 5.0.2.
You can find the entire article here.
See this piece of MySQL reference manual:
It is sometimes possible for a multiple-table view to be updatable, assuming that it can be processed with the MERGE algorithm. For this to work, the view must use an inner join (not an outer join or a UNION). Also, only a single table in the view definition can be updated, so the SET clause must name only columns from one of the tables in the view. Views that use UNION ALL are not permitted even though they might be theoretically updatable, because the implementation uses temporary tables to process them.
For a multiple-table updatable view, INSERT can work if it inserts into a single table. DELETE is not supported.
INSERT DELAYED is not supported for views.
精彩评论