How to Create Nonclustered Index in SQL
In this article I am going to explain how to create nonclustered index in SQL.
Index in SQL is used to quickly access the data from table or view. Indexes are created on table or view. Database have large amount of data like thousands of tables and view. When we try to access this data it takes more time.
SQL provide a way known as index through we can access a specific data quickly. CREATE INDEX statement is used to create a index.
Type of index in SQL
- Clustered index
- Non clustered index
- Unique index
- Columnstore index
What is Nonclustered Index
In nonclustered index logical address and physical address are not same. You can define a nonclustered index on a view or table with a clustered index or on a heap. CREATE INDEX statement is used to create a nonclustered index in SQL.
Statement that create cluster index
IF EXISTS (SELECT name FROM sys.indexes
WHERE name = N'non_cl_index_student')
DROP INDEX non_cl_index_student ON Purchasing.ProductVendor;
CREATE INDEX IX_ProductVendor_VendorID
ON dbo.studentinfo (s_id);