Collections:
Creating an Index on a View in SQL Server
How To Create an Index on a View in SQL Server?
✍: FYIcenter.com
If you need to search and sort data in a view with a large number of row, you may want to create an index on the view to speed up your search process.
The tutorial exercise below shows you how to create a unique clustered index on a view.
DROP VIEW fyi_links_view; GO CREATE VIEW fyi_links_view (ID, UrlReversed) AS SELECT id, REVERSE(url) FROM fyi_links_copy WHERE counts > 1000; GO CREATE UNIQUE CLUSTERED INDEX date_string ON fyi_links_view (ID); GO Cannot create index on view 'fyi_links_view' because the view is not schema bound. ALTER VIEW fyi_links_view (ID, UrlReversed) WITH SCHEMABINDING AS SELECT id, REVERSE(url) FROM dbo.fyi_links_copy WHERE counts > 1000; GO CREATE UNIQUE CLUSTERED INDEX date_string ON fyi_links_view (ID); GO EXEC SP_HELP fyi_links_view; GO index_name index_description index_keys ----------- ------------------------------------ ---------- date_string clustered, unique located on PRIMARY ID
⇒ Using INSERT, UPDATE and DELETE Statements in SQL Server
⇐ SCHEMABINDING - Binding Views to Underlying Tables in SQL Server
2016-11-03, 2152🔥, 0💬
Popular Posts:
Where to find answers to frequently asked questions on Storage Engines: MyISAM, InnoDB and BDB in My...
How To Break Query Output into Pages in MySQL? If you have a query that returns hundreds of rows, an...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
How to obtain the number of rows found by the last SELECT statement using the FOUND_ROWS() function?...
Why I Can Not Enter 0.001 Second in DATETIME values in SQL Server Transact-SQL? If you enter millise...