0

我有表 _house,字段“soft_delete”默认为 0。

然后我有一个视图来检查未删除的条目,因此我有

CREATE VIEW house AS 
SELECT * FROM _house where soft_delete = 0;

但现在的问题是,每次我修改表 _house 时,我都需要重新更新我的视图,以免损坏。
所以每次修改表_house后,我执行

ALTER VIEW house AS 
SELECT * FROM _house where soft_delete = 0;

我想找到一种更简单的方法来执行上述更改脚本,因此我尝试创建一个内部带有“更改视图”的过程/函数,但 mysql 似乎禁止我这样做。

问题 :

  • 还有其他解决方案来简化这种“冗余”操作吗?
4

1 回答 1

0

The view definition is “frozen” at creation time, so changes to the underlying tables afterward do not affect the view definition. For example, if a view is defined as SELECT * on a table, new columns added to the table later do not become part of the view.

资源

于 2013-07-17T08:57:42.367 回答