By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
CREATE TABLE
INSERT 0 3
INSERT 0 2
| id | title | hex | rgb |
|---|---|---|---|
| 1 | red | #ff0000 | 255, 0, 0 |
| 2 | blue | #00ff00 | 0, 255, 0 |
| 3 | green | #0000ff | 0, 0, 255 |
SELECT 3
| id | colour_id |
|---|---|
| 65d47b4d5b5db | 1 |
| 65d47b9402fef | 3 |
SELECT 2
ERROR: insert or update on table "car" violates foreign key constraint "car_colour_id_fkey" DETAIL: Key (colour_id)=(4) is not present in table "colour".