Creating Basic Indexes

Now that you understand what indexes are, how they work, and the different types of indexes, it's time to start creating some indexes. The following sections will step you through creating both clustered and nonclustered indexes.

Creating a Clustered Index

You will now create a clustered index in the most common way—by creating a primary key. In order to perform the steps in Exercise 10.1, you must first create a table in the Books database with the following code:

CREATE TABLE dbo.Customers (
    CustomerID int NOT NULL,
    FirstName varchar(50),
    LastName varchar(50),
    eMail varchar(60),
    Phone int,
    City varchar(40),
    State char(2),
    ZipCode int
    );

You can enter and execute this code in a New Query window within SSMS. Ensure that ...

Get SQL Server® 2008 Administration: Real World Skills for MCITP Certification and Beyond now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.