What are Views? Explain their benefits and limitations.

Senior MS SQL

Answer

A view is a named, virtual table defined by a SELECT query. It does not store data itself (unless indexed) but presents a reusable query abstraction.

Benefits:

  • Abstraction and simplification: Hides complex joins and expressions behind a simple interface.
  • Security: Exposes only selected columns/rows while hiding underlying schemas and tables.
  • Reuse: Centralizes business logic or filter logic so that many queries can benefit from a single definition.
  • Schema evolution: Application code can query the view even if underlying tables change, as long as the view's contract is preserved.

Limitations:

  • Views can become stacked (views on views), leading to overly complex, hard-to-tune execution plans.
  • Not all views are updatable; complex joins, aggregates, and DISTINCT can prevent direct DML.
  • They do not inherently improve performance unless combined with indexed views or used to encapsulate optimal query patterns.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice