Codington
0 of 8 problems solved • 0%

Exercise prompt

Reserve a Unique Service Code

UNIQUE lets PostgreSQL reject a second row with the same code. A date column stores a calendar date. You can enter one as DATE '2026-04-01'.

Example

CREATE TABLE jobs (id integer, code text UNIQUE);

Your task

Create services with id integer, code text and launched_on date, in that order. Require unique codes. Register api (ID 1) and web (ID 2), both launched on 2026-05-12.

After both rows are visible, try a separate INSERT with ID 3 and the code api again. Read the duplicate-key error and check that the table still has two rows.

Opening the database…