大虾们帮帮忙:
我的视图有三个基表,帮助上说,多个基表的视图,只有创建索引后,才能添加instead of 触发器。
但是with schemabinding创建后,无法create unique clustered index,是啥原因呢?
源码如下:
set ANSI_PADDING on
set ANSI_NULLS on
set QUOTED_IDENTIFIER on
set ANSI_WARNINGS on
set ARITHABORT on
set CONCAT_NULL_YIELDS_NULL on
drop view testBookInfoview
go
--创建视图:
create view testBookInfoView with schemabinding
AS
SELECT TOP 100 PERCENT RTRIM(dbo.tblBook.BookName) AS 书名,
dbo.tblAuthor.FirstName AS 作者名, dbo.tblAuthor.LastName AS 作者姓,
RTRIM(dbo.tblPubs.PubName) AS 出版社, dbo.tblBook.BookType AS 类型,
dbo.tblBook.PubDate AS 出版日期, dbo.tblBook.StartTime AS 开始日期,
dbo.tblBook.TotalPages AS 页数, dbo.tblBook.Description AS 书评,
dbo.tblBook.idBook
FROM dbo.tblBook INNER JOIN
dbo.tblPubs ON dbo.tblBook.idPub = dbo.tblPubs.idPub INNER JOIN
dbo.tblAuthor ON dbo.tblBook.idAuthor = dbo.tblAuthor.idAuthor
ORDER BY dbo.tblBook.BookType, dbo.tblBook.PubDate
go
select * from testBookInfoView
--创建索引
create unique clustered index ind_BookInfo on testBookInfoView(idBook)
提示说“无法 index 视图 'BookNotes.dbo.testBookInfoView'。它包含一个或多个不允许使用的构造。”