How to: Create Clustered Indexes

In Microsoft SQL Server databases you can create a clustered index. In a clustered index, the physical order of the rows in the table is the same as the logical (indexed) order of the index key values. A table can contain only one clustered index. UPDATE and DELETE operations are often accelerated by clustered indexes because these operations require large amounts of data to be read. Creating or modifying a clustered index can be time-consuming, because it is during these operations that the table's rows are reorganized on disk.

Consider using a clustered index for:

  • Columns that contain a limited number of unique values, such as a state column that contains only 50 unique state codes.

  • Queries that return a range of values, using operators such as BETWEEN, >, >=, <, and <=.

  • Queries that return large result sets.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To create a clustered index

  1. In Server Explorer, right-click the table for which you want to create a clustered index and click Open Table Definition.

    The table opens in Table Designer.

  2. From the Table Designer menu, click Indexes/Keys.

  3. In the Indexes/Keys dialog box, click Add.

  4. Select the new index in the Selected Primary/Unique Key or Index list.

  5. In the grid, select Create as Clustered, and choose Yes from the drop-down list to the right of the property.

    The index is created in the database when you save the table.

See Also

Reference

Indexes/Keys Dialog Box

Other Resources

Working with Indexes