-- Example table
CREATE TABLE accounts (
user_id serial PRIMARY KEY,
username VARCHAR ( 50 ) UNIQUE NOT NULL,
password VARCHAR ( 50 ) NOT NULL,
email VARCHAR ( 255 ) UNIQUE NOT NULL,
created_on TIMESTAMP NOT NULL,
last_login TIMESTAMP
);
CREATE TABLE cities (
city_id serial PRIMARY KEY,
city_name VARCHAR (255) NOT NULL,
population INT NOT NULL CHECK (population >= 0)
);
CREATE TABLE films_recent AS
SELECT * FROM films WHERE date_prod >= '2002-01-01';
CREATE TABLE table_name (
column_name TYPE column_constraint,
table_constraint table_constraint
) INHERITS existing_table_name;
CREATE TABLE holiday_calender (
hcl_id bigserial NOT NULL,
hcl_country integer,
hcl_company integer,
hcl_date timestamp NULL,
hcl_description varchar(500) NULL,
hcl_active int4 NOT NULL,
CONSTRAINT holiday_calender_pkey PRIMARY KEY (hcl_id)
);
pg_dump -t 'schema-name.table-name' --schema-only database-name