INDEXED VIEW (WITH SCHEMABINDING)
INDEXED VIEW (WITH SCHEMABINDING) is a SQL statement in the Views category. SQL Server: a view with a unique clustered index. The view's data is physically stored, dramatically improving performance. The syntax is CREATE VIEW view_name WITH SCHEMABINDING AS select_statement; CREATE UNIQUE CLUSTERED INDEX idx ON view (col);. It returns indexed view. A typical example: CREATE VIEW sales_summary WITH SCHEMABINDING AS SELECT product_id, SUM(quantity) AS total_qty, COUNT_BIG(*) AS count FROM dbo.order_items GROUP BY product_id; CREATE UNIQUE CLUSTERED INDEX idx_sales ON sales_summary (product_id); -- Now the view is materialized/indexed -- Queries against this view use the index directly A close relative is CREATE VIEW, which creates a virtual table based on a SELECT query. Think of it as a saved query that acts like a table. A close relative is DROP VIEW, which removes a view from the database. Does not affect the underlying tables. A close relative is ALTER VIEW, which modifies an existing view definition.