Foreign keys
Most general syntax
This works, because the foreign key declaration refers to a table
that already exists:
create table P(
p_id int not null,
x int
);
create table F(
f_id int not null primary key,
p_id int references P,
y int
);
This does not, because the foreign key declaration refers to a table
that does not exist:
create table F(
f_id int not null primary key,
p_id int references P,
y int
);
ERROR: relation "P" does not exist
create table P(
p_id int not null,
x int
);
|