SQL Create Index on Table

Add a Table Index

  • In a relational database management system, an index is a mechanism for boosting performance.
  • This is true for the selecting of data from tables, but not for the updates, it may be slow down the performance.
    Syntax:
    MySQL, Oracle, SQL server, PostgreSQL:
    CREATE [UNIQUE] INDEX index_name ON table_name (column_name)
    Example:
    create index CustomerID on Orders (Customer_id)
  • We can create a Composite index of two or more columns (fields) when it will provide the best search as a unit because of their logical relationship.

    Example:
    create index Fullname on Customer (First_name, Last_Name);
  • A unique index is one in which no two rows are permitted to have the same index value.
  • We usually create a unique index on the primary keys columns.
    Example:
    create unique index TitleIndex on bookstore (PUBLISHER);
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.