我们公司的某个人决定使用 3 个视图来支持网页,并且它们必须包含相同的列子集。所以我有这样的定义:
CREATE VIEW EmailReceivedView
AS
SELECT
dbo.EmailReceived.ID
, ...lots of columns
FROM dbo.EmailReceived
LEFT OUTER JOIN ...more tables
--Emails related to reviews
CREATE VIEW ReviewEmailReceivedView
AS
SELECT RV.ReviewID, V.*
FROM ReviewEmailReceived RV
INNER JOIN EmailReceivedView V ON EmailReceivedID = V.ID
--Emails related to grants
CREATE VIEW GrantEmailReceivedView
AS
SELECT GV.GrantID, V.*
FROM GrantEmailReceived GV
INNER JOIN EmailReceivedView V ON GV.EmailReceivedID = V.ID
现在我在从属视图中做 V.* 的原因是,如果支持视图发生更改,我希望从属视图反映更改。但这不会在 SQL Server 中发生,除非我将脚本作为 ALTER 脚本重新运行。为什么不?有没有办法确保对支持视图的更改自动反映在依赖项中?