Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
B-trees
3. How to create an index
Summary

Instruction

In SQL, the simplest type of index is created on a single column. Given the following table...

CREATE TABLE player (
  nick varchar(32) PRIMARY KEY,
  points integer
);

... you can create an index on the column points like this:

CREATE INDEX points_index
ON player(points);

Behind the scenes, the database will create an index for you. You won't see its contents, but it'll automatically be used when queries filter rows using the points column. We'll talk more about that in the next parts of the course.

Exercise

Now it's your turn to create a simple index. You're given the same table:

CREATE TABLE player (
  nick varchar(32) PRIMARY KEY,
  points integer
);

Create an index named nick_index on the column nick.