Cannot create index on view #39;View_Table_Name#39; because the view is not schema bound(无法在视图“View_Table_Name上创建索引,因为该视图未绑定架构)
问题描述
我在存储过程(SQL-Server)中使用视图.为了提高性能,我尝试创建该视图的 INDEX.
I am using Views in my stored Procedure(SQL-Server). For Improving Performance, I have tried to created INDEX of that View.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER VIEW VW_Table_Name
AS
SELECT Col1,Col2,Col3 FROM Table_Name
GO
CREATE UNIQUE CLUSTERED INDEX Index_Name ON [VW_Table_Name](Col1)
GO
这里我收到了类似的错误
Here I am getting the Error like
消息 1939,级别 16,状态 1,第 1 行无法在视图VW_FML"上创建索引,因为该视图未绑定架构.
Msg 1939, Level 16, State 1, Line 1 Cannot create index on view 'VW_FML' because the view is not schema bound.
我们可以在 SQL Server 中为视图创建索引吗?
Can we created Index for View in SQL Server ?
推荐答案
索引视图有很多限制:没有子查询、没有联合、没有外连接等.参见 这篇文章 了解更多详情.但对于您的情况,您只需要创建具有架构绑定的视图.
There are a number of restrictions on indexed views: no subqueries, no unions, no outer joins, etc. See this article for more details. But for your case, you simply need to create the view with schema binding.
CREATE VIEW VW_Table_Name WITH SCHEMABINDING
AS
SELECT Col1,Col2,Col3 FROM Table_Name
GO
这篇关于无法在视图“View_Table_Name"上创建索引,因为该视图未绑定架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法在视图“View_Table_Name"上创建索引,因为该视图未绑定架构


基础教程推荐
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01