Why can I change the table referenced by the view with SCHEMABINDING?

Looking for some clarification on SCHEMABINDING. I read on the forum that if you create a view using Schemabinding, the base table cannot be changed.

So, I created a view with SCHEMABINDING and was able to remove the column from the base table.

So now I am confused about what the purpose of SCHEMABINDING is, and when and where should it be used?

NOTE . I tried to reset the base table, and I could not do it due to SCHEMABINDING.

0
source share
1 answer

SCHEMABINDING . . :

CREATE TABLE dbo.foo(a INT, b INT);
GO

CREATE VIEW dbo.vFoo 
WITH SCHEMABINDING 
AS
  SELECT a FROM dbo.foo;
GO

a, b :

ALTER TABLE dbo.foo DROP COLUMN b;
GO

a, :

ALTER TABLE dbo.foo DROP COLUMN a;
GO

:

Msg 5074, 16, 1, 17
"vFoo" "a".
Msg 4922, 16, 9, 17
ALTER TABLE DROP COLUMN , .

, , , . , :

... , .

, "". , , , , , .

+6

All Articles