O'Reilly logo

Sams Teach Yourself MySQL by Chris Newman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding Keys and Indexes

The terms keys and indexes are often used interchangeably. A key column stores values that are used to filter rows in the table, either in the WHERE clause when querying that table or as part of a join to indicate the relationship between two tables.

A key column in MySQL is always indexed, but you can create an index on any table column or on multiple columns.

Primary Keys

Each table can contain only one primary key, which is a unique identifier for each row in the table. Often the primary key is an AUTO_INCREMENT column so that a new unique number is assigned automatically for each row added to the table.

You can be sure that when you query a table using a filter on a primary key field, MySQL will return only ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required