首页 / MYSQL / 更新MySQL中的视图
更新MySQL中的视图
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了更新MySQL中的视图,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1691字,纯文字阅读大概需要3分钟。
内容图文
![更新MySQL中的视图](/upload/InfoBanner/zyjiaocheng/910/254f284d6b8d42ad8ca179fa6c8514ef.jpg)
我正在创建一个视图来向用户显示他/她的数据,但我也希望用户能够在这些视图中的某些字段中进行更改.视图中所做的更改是否也反映在基表中?
另外,我是否可以更新由多个基表组成的视图?
解决方法:
如Updatable and Insertable Views所述:
Some views are updatable. That is, you can use them in statements such as 07001, 07002, or 07003 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. To be more specific, a view is not updatable if it contains any of the following:
Aggregate functions (07004, 07005, 07006, 07007, and so forth)
DISTINCT
GROUP BY
HAVING
07008 or 07009
Subquery in the select list
Certain joins (see additional join discussion later in this section)
Nonupdatable view in the
FROM
clauseA subquery in the
WHERE
clause that refers to a table in theFROM
clauseRefers only to literal values (in this case, there is no underlying table to update)
Uses
ALGORITHM = TEMPTABLE
(use of a temporary table always makes a view nonupdatable)Multiple references to any column of a base table.
[ deletia ]
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 07008). Also, only a single table in the view definition can be updated, so theSET
clause must name only columns from one of the tables in the view. Views that use 07009 are not permitted even though they might be theoretically updatable, because the implementation uses temporary tables to process them.
内容总结
以上是互联网集市为您收集整理的更新MySQL中的视图全部内容,希望文章能够帮你解决更新MySQL中的视图所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。