且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过sql视图将数据插入到多个表中

更新时间:2022-04-05 22:44:28

MySQL参考手册对此内容进行了说明:

The MySQL Reference Manual says this about updatable views:

有些观点是可更新的.也就是说,可以在诸如UPDATEDELETEINSERT之类的语句中使用它们来更新基础表的内容.为了使视图可更新,视图中的行与基础表中的行之间必须存在一对一的关系.还有某些其他构造会使视图不可更新.

Some views are updatable. That is, you can use them in statements such as UPDATE, DELETE, or INSERT 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.

可以为可更新视图提供WITH CHECK OPTION子句,以防止对select_statement中的WHERE子句为true的行进行插入或更新. WITH CHECK OPTION子句在MySQL 5.0.2中实现.

The WITH CHECK OPTION clause can be given for an updatable view to prevent inserts or updates to rows except those for which the WHERE clause in the select_statement is true. The WITH CHECK OPTION clause was implemented in MySQL 5.0.2.

您可以在此处找到整篇文章