1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Index In SQL Server Part 1

Discussion in 'Database' started by Sagar Jaybhay, Feb 11, 2020.

  1. Sagar Jaybhay

    Sagar Jaybhay New Member

    Joined:
    Jan 28, 2019
    Messages:
    23
    Likes Received:
    12
    Trophy Points:
    3
    Gender:
    Male
    Occupation:
    Sr. Software Developer
    Location:
    Pune
    Home Page:
    Index is used to find data from the table quickly. An index is created on views and tables. It is similar to the book index.
    If you apply index it will improve the query performance drastically. If there is no index then the query engine checks every row from beginning to end and it will require time which is bad and this is called a Table scan.
    You can create an index in the SQL server in 2 ways. 1) by Query 2) Graphical Interface.
    The index is a special kind of data structures which is associated with table and views by the help of this you can increase the performance of the query.


    General Syntax:
    Code:
    Create index index_name on table_name (column_name asc)
    Example
    Code:
    create index in_employee on Employee (empid asc)
    The above query creates an in_employee index on the Employee table on the empid column.

    To find out all the indexes created on the table using below command

    Code:
    sp_helpindex Employee
    In this sp_heplindex is a system stored procedure.

    How to drop the index?
    Code:
    Drop index tablename.index_name;
    Ex.
    Code:
    Drop index employee.index_name
    There are different types of indexes present in the SQL Server.
    1) Clustered
    2) Non-Clustered
    3) Unique
    4) Filtered
    5) XML
    6) Full text
    7) Spatial
    8) ColumnStore
    9) Index with included column
    10) Index on a computed column
     

Share This Page