视图上的工作如何CHECK OPTION
?尝试更新视图时,它会成功。
CREATE TABLE [dbo].[Test](
[Country] [nvarchar](20) NULL
) ON [PRIMARY]
INSERT [Test] VALUES ('England'), ('USA'), ('Australia');
CREATE VIEW dbo.TestView AS
SELECT Country FROM dbo.Test
WHERE Country = N'USA'
WITH CHECK OPTION;
我尝试通过视图插入新行,但由于出现预期的错误消息,它按预期失败WITH CHECK OPTION
The attempted insert or update failed because the target view either specifies WITH CHECK OPTION
INSERT INTO dbo.TestView (Country) VALUES (N'Canada');
但是,此更新意外成功:
UPDATE dbo.TestView SET Country = N'ddsffd';
执行时不返回任何行SELECT * FROM dbo.TestView
。
这里发生了什么?