[英]Updating underlying tables of indexed view but the column is not present in the view
假设我有两张桌子,Country 和 City。
Country(id, fname, president_name)
City(id, cname, country_id_fk, mayor_name)
City 表对 Country 表具有外键依赖性。 假设我在这样的表上创建了一个索引视图:
CREATE VIEW CountryCity
WITH SCHEMABINDING
AS
SELECT Country.fname, City.cname
FROM Country INNER JOIN City
ON Country.id = City.country_id_fk;
GO
并在该视图上创建唯一的聚集索引
CREATE UNIQUE CLUSTERED INDEX ucidx_cc
ON CountryCity(cname, fname);
GO
请注意,我在视图中没有president_name
。 如果我更新 Country 表中的president_name
,是否会影响CountryCity
视图。
我的意思是说影响是因为我们在该表上有一个索引视图,所以在Country
表的更新过程中会出现性能问题吗?
您基本上可以拥有包含特定列的索引。 当您更新其他列时,如果它们未包含在索引中,则不会应用维护其数据的操作。
另外,SQL Engine 可以为每张表维护很多索引,因此无需担心如此简单的设计。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.