Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Single-column indexes
3. Creating indexes on VARCHAR columns
Multi-column indexes
Additional options when creating indexes
Summary

Instruction

Good job! We've been given the same table:

CREATE TABLE player (
  id integer PRIMARY KEY,
  first_name varchar(64),
  last_name varchar(64),
  year_born integer,
  country varchar(64),
  current_points integer
);

We previously created an index on an INTEGER column. Now, we'd like to create another one – this time, on the column country, which is a VARCHAR column. The syntax is the same:

CREATE INDEX player_country_index
ON player(country);

When is such an index useful? We'll find out in a second.

Exercise

We're still working on the same table:

CREATE TABLE driver (
  id integer PRIMARY KEY,
  full_name varchar(128),
  year_born integer,
  city varchar(64),
  rating decimal(3, 2),
  ride_count integer
);

We often search for drivers based on their name. Create an index named name_index on the column full_name.