PostgreSQL > Tables
Creating Tables
Create typical type with default date:
create table address (
id bigserial primary key,
"name" varchar(100) not null,
create_at timestamp without time zone default (now() at time zone 'utc')
);
Create table with foreign key
create table contact (
id bigserial primary key,
address_id bigint not null,
"name" varchar(100) not null,
create_at timestamp without time zone default (now() at time zone 'utc'),
constraint fk_address foreign key(address_id) references address(id)
);
Create table IF NOT EXISTS
create table if not exists address (
...
)