Index in SQL


An index is used to speed up the performance of queries. It does this by reducing the number of database data pages that have to be visited/scanned.
In SQL Server, a clustered index determines the physical order of data in a table. There can be only one clustered index per table (the clustered index IS the table). All other indexes on a table are termed non-clustered.
  • SQL Server Index Basics
  • SQL Server Indexes: The Basics
  • SQL Server Indexes
  • Index Basics
  • Index (wiki)



    INDEXES -to find data easily UNIQUE INDEX-duplicate values are not allowed SYNTAX FOR INDEX;
             CREATE INDEX INDEX_NAME ON TABLE_NAME(COLUMN);
    SYNTAX FOR UNIQUE INDEX;
               CREATE UNIQUE INDEX INDEX_NAME ON TABLE_NAME(COLUMN);


     Well in general index is binary tree. There are two types of indexes: clustered and nonclustered. Clustered index creates a physical order of rows (it can be only one and in most cases it is also a primary key - if you create primary key on table you create clustered index on this table also). Noclustered index is also a binary tree but it doesn't create a physical order of rows. So the leave nodes of nonclustered index contan PK (if it exists) or row index. Indexes are used to increase speed of search. Because it that case it is O(log N). Indexes is very large and interesting topic. I can say that creating indexes on lagre database is some kind of art sometimes.

No comments:

Post a Comment