Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indexed Views with SCHEMABINDING

We have a number of indexed views, which of course require SCHEMABINDING. The base tables supporting these views are involved in replication. Our DBA recently had to re-create the replication and said that all these indexed views gave him grief because he couldn't drop the base tables and re-create them, which I guess is what replication does.

He told me that, in each of the indexed views, he commented out the 'SCHEMABINDING' and saved the view definition. When he did this, what happened to the associated index of each view? Was it deleted? Will I have to go back to each view, include the SCHEMABINDING command and then re-create each associated index?

like image 733
Hosea146 Avatar asked Feb 23 '23 10:02

Hosea146


1 Answers

You cannot have an index on a view without schemabinding, so yes the indexes were removed and you have to add schemabinding back and re-create the indexes. http://msdn.microsoft.com/en-us/library/aa933148%28v=sql.80%29.aspx

EDIT: @RedFilter, I just did a test and whether you remove schemabinding by ALTERing the view or DROPing and re-creating it, the indexes are removed.

like image 133
minnow Avatar answered Mar 21 '23 03:03

minnow