Primary keys - the basics
Single-column primary keys
Multicolumn primary keys
Auto-increment columns and sequences
Revision
28. Revision #2

Instruction

100% correct! Are you ready for the second task?

Exercise

We want a table called parcel which will register pieces of land within our country. The table has the following columns:

  • city - up to 25 characters,
  • street - up to 25 characters,
  • num - an integer,
  • area - a real number,
  • state_owned - a yes/no field.
We want the first three columns to form the primary key.

Stuck? Here's a hint!

Type

CREATE TABLE parcel (
    city varchar(25),
    street varchar(25),
    num int,
    area real,
    state_owned bool,
    primary key (city, street, num)
);

Console

Code editor

Result

TableConsole