Advertisement
Advanced SQL Server, Views

What happens to the performance and correctness of a view if the underlying tables change significantly after the view was originally created?

Short answer

A regular, non schema bound view does not store any data itself and simply re-executes its underlying query each time it is accessed, meaning it will always reflect the current structure and data of the underlying tables, though a view without schema binding can break…

Save SQL Server mock interview
Advertisement
AModel answer
A regular, non schema bound view does not store any data itself and simply re-executes its underlying query each time it is accessed, meaning it will always reflect the current structure and data of the underlying tables, though a view without schema binding can break unexpectedly if a referenced column is renamed or removed, since SQL Server does not automatically prevent this kind of change for unprotected views.
-- A regular view is not protected from underlying changes
CREATE VIEW dbo.CustomerView AS SELECT CustomerId, Name FROM Customers;
-- If the Name column is later renamed, this view will break
Real-world example
A team encounters a broken report and discovers a column referenced by an underlying view had been renamed without anyone realizing the view depended on it, prompting them to add schema binding to their important views going forward.
Likely follow-ups
  • How do you identify all views that depend on a specific table before making a schema change?
  • What tools help detect broken views proactively before they cause a production issue?
Related topics