The CREATE INDEX Statement

Most systems have a command with syntax similar to this:

CREATE [UNIQUE] INDEX index_name
ON table_name (column_name)

The column and table names specify the column you want indexed and the table that contains it. To create an index on the au_id column of the authors table, the command is

SQL
create index auidind
on authors (au_id)
[index created]

It's a good idea to plan and create your indexes when you create your table, particularly if you need the indexes to guarantee uniqueness. However, SQL allows you to create indexes after there's data in a table, and this may be more efficient for some situations.

Most systems ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition 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.