INDEX

  • An index is a schema object that contains an entry for each value that appears in the indexed columns of the table or cluster and provides direct, fast and access to roaows
  • They are automatically created when PRIMARY KEYS and Unique constraints are created
  • Indexes are similar to the index in a book; they provide a way to quickly find a specific page.

Syntax

Text description of statements_527.gif follows

Types of Indexes

  • Primary Index: This index uniquely identifies each record in the table and must be unique and not null.
  • Unique Index: Similar to the primary index, it enforces uniqueness on a column, but it does not have to be the primary key.
  • Clustered Index: Determines the physical order of data in the table. A table can have only one clustered index.
  • Non-Clustered Index: Creates a separate structure to store the index, keeping the data rows in a separate location from the actual index.

By creating an index on the LastName column, the database can efficiently find the rows with the specified last name, resulting in faster query performance.

Example 2: Creating Index on 1 column

Creating Index on 2 columns

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top