codescracker


sql

SQL Create Index



« Previous Tutorial Next Tutorial »


SQL CREATE INDEX statement is used to create indexes in tables. Indexes in SQL, allows the database application to find the data without reading the whole table.

Indexes are used to find the data as fast as possible. Indexes are only used to speed up the searches and queries, therefore users can't see the indexes.

SQL CREATE INDEX Statement

Here is the general form of the CREATE INDEX statement in SQL. In this case, duplicate values are allowed:

CREATE INDEX index_name
ON table_name (column_name)

SQL CREATE UNIQUE INDEX Statement

Here is the general form of the CREATE UNIQUE INDEX statement in SQL. In this case, duplicate values aren't allowed:

CREATE UNIQUE INDEX index_name
ON table_name (column_name)

SQL CREATE INDEX Example

Here is an example of SQL CREATE INDEX statemnt. The Following SQL Statements creates an index named "PIndex" on the column "LastName" in the table "Students":

CREATE INDEX PIndex
ON Students (LastName)

If you want to create an index on a combination of columns, then you can list the column names within the parentheses, separated by commas.

Let's look at the following SQL Statements:

CREATE INDEX PIndex
ON Students (LastName, FirstName)

« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test