In pgAdmin there is no way to add a column to an existing table and make it a primary key at the same time, because this is hardly possible.
The primary key column must contain unique non-zero values. After adding a column to an existing table, it contains NULL values. Therefore, before adding UNIQUE or PRIMARY KEY you must enter unique values.
There is an exception to this rule. If you add serial , unique values ββare inserted automatically. In this case, you can also immediately determine its PRIMARY KEY:
ALTER TABLE student ADD COLUMN student_number serial PRIMARY KEY;
This works in PostgreSQL 9.1. I'm also not sure if this is done in older versions.
pgAdmin does not include this special case for serial columns in the "New Column ..." dialog box at this time (version 1.14).
Erwin Brandstetter Mar 16 2018-12-12T00: 00Z
source share