PostgreSQL Alter table add primary key to existing table
Add primary key to existing table
How to add primary key to existing table. Alter syntax and example.
Syntax
ALTER TABLE tabel_name ADD PRIMARY KEY (column_name);
Create table
CREATE TABLE users( userid numeric, username varchar(100), userpass varchar(250), usermail varchar(50) );
Example Add primary key
ALTER TABLE users ADD PRIMARY KEY (userid);