foreign key postgresql code example
Example 1: create table postgresql foreign key
CREATE TABLE so_items (
so_id INTEGER,
...
FOREIGN KEY (so_id) REFERENCES so_headers (id)
);
Example 2: foreign key plsql
CREATE TABLE supplier
( supplier_id numeric(10) not null,
supplier_name varchar2(50) not null,
contact_name varchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
);
CREATE TABLE products
( product_id numeric(10) not null,
supplier_id numeric(10) not null,
CONSTRAINT fk_supplier
FOREIGN KEY (supplier_id)
REFERENCES supplier(supplier_id)
);
Example 3: psql create table foreign keys
create table lists(
id_list serial not null primary key,
id_user int references users(id_user),
is_temp int
);