Index In SQL Server Part VI
Index In SQL Server
Index :
- Indexes are used to improve the performance of searching, Because they are in sequential format it helps the searching operation.
- An index is an on-disk structure associated with a table or view that speeds retrieval of rows from the table or view.
- An index contains keys built from one or more columns in the table or view.
- These keys are stored in a structure (B-tree) that enables SQL Server to find the row or rows associated with the key values quickly and efficiently.
A table or view can contain the following two types of indexes :
1) Clustered Index :
- Clustered Index arranges the indexes in the form of the Balanced Tree Structure(B-Tree).
- In SQL server clustered index is created automatically, when a primary key is created.
- There can be only one clustered index per table, because the data rows themselves can be stored in only one order.
Creating Clustered Index in SQL Server :
1) Go to Design of a table, then Right click on column and select Indexes/Keys :
2) The Table Designer set Create As Clustered as Yes,then Clustered Index is created Successfully :
2) Non-Clustered Index :
- In Non-Clustered Index, it also arranges a Balanced tree structure.
- There can be multiple non-clustered index per table, because the data rows themselves can be stored in multiple order.
Creating Non-Clustered Index in SQL Server :
1) Go to Design of a table, then Right click on column select and open Indexes/Keys then click Add & Select the column name :
2) Select type to index :
SQL Plan :
- The SQL plan is nothing but is the plan by SQL server created while executing.
- Then the query is written completely.
- You can directly click the “Display Estimated Execution Plan” toolbar button :
Example :
Comments
Post a Comment