ADD key CONSTRAINTs to a table
You can add the PRIMARY KEY keyword after the column_name that should be unique. This, of course, only works for new tables
CREATE TABLE products(
product_no integer primary key,
name text,
price numeric
)
or
CREATE TABLE products(
product_no integer,
name text,
price numeric,
primary key(product_no, name)
)
To add a primary key to an existing table. You add it by:
ALTER TABLE table_name
ADD CONSTRAINT some_name PRIMARY KEY (column_name)
ALTER TABLE universities
ADD CONSTRAINT university_pk PRIMARY KEY (id);