Solve “Deduplicate events with ROW_NUMBER”

Free. Runs in your browser, no install.

SQL · Query Optimization

Clustered vs non-clustered index

Hardclustered indexnon-clusteredindex

Interview question

What is the difference between a clustered and a non-clustered index?

How to answer

The short answer

A clustered index determines how the table's rows are physically/logically organized around the index key, depending on the database implementation.

A non-clustered index is a separate index structure that points to the underlying rows.

A table usually gets only one clustered organization/index, because the rows cannot be physically ordered two different ways at once.

It can have many non-clustered indexes.

Note: exact clustered-index behavior differs by database.

Lock it in with a real drill

You remember an answer longer once you have used it. Try a hands-on problem on this concept.

Open related drill