Skip to content

Commit d078fbc

Browse files
committed
Add type continent_enum
Closes: #75
1 parent 5c305e3 commit d078fbc

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

scripts/world.sql

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@ CREATE TABLE city (
2020

2121
COMMENT ON COLUMN city.local_name IS 'City local name';
2222

23+
CREATE TYPE continent_enum AS ENUM (
24+
'Asia',
25+
'Europe',
26+
'North America',
27+
'Africa',
28+
'Oceania',
29+
'Antarctica',
30+
'South America'
31+
);
32+
2333
CREATE TABLE country (
2434
code character(3) NOT NULL,
2535
name text NOT NULL,
26-
continent text NOT NULL,
36+
continent continent_enum NOT NULL,
2737
region text NOT NULL,
2838
surface_area real NOT NULL,
2939
indep_year smallint,
@@ -35,8 +45,7 @@ CREATE TABLE country (
3545
government_form text NOT NULL,
3646
head_of_state text,
3747
capital integer,
38-
code2 character(2) NOT NULL,
39-
CONSTRAINT country_continent_check CHECK ((((((((continent = 'Asia'::text) OR (continent = 'Europe'::text)) OR (continent = 'North America'::text)) OR (continent = 'Africa'::text)) OR (continent = 'Oceania'::text)) OR (continent = 'Antarctica'::text)) OR (continent = 'South America'::text)))
48+
code2 character(2) NOT NULL
4049
);
4150

4251
COMMENT ON COLUMN country.gnp IS 'GNP is Gross national product';

0 commit comments

Comments
 (0)