Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Automatically-created indexes
5. CREATE UNIQUE INDEX – exercise
SQL index best practices
Summary

Instruction

Okay, it's time you created a UNIQUE INDEX by yourself. Here's the syntax:

CREATE UNIQUE INDEX index_name
ON table_name(column_name);

Exercise

We've got the following definition of the invoice table:

CREATE TABLE invoice (
  id integer PRIMARY KEY,
  number varchar(18) UNIQUE,
  qr_code_url varchar(512),
  issue_date date,
  customer_id integer,
  amount decimal(10, 2),
  currency char(3)
);

The company wants to test a new feature where every invoice has a UNIQUE QR code for quicker access. Note that we've added a column named qr_code_url.

Your task is to create a UNIQUE index named unique_qr_url on the column qr_code_url.

Stuck? Here's a hint!

Remember to use a UNIQUE keyword.