I have a table in the postgres for which I dint assign any primary key as the values are repeated, but now I want to add primary key for it by altering the table and adding serial column as a primary key . Will it allow me to do that, will it assign the serial numbers for the existing data after I alter the table? What would be the best practice to do that?
Asked
Active
Viewed 155 times
0
-
1Please fix spelling. This will help make the question easy to understand and find for other users in future. – Mar 24 '17 at 14:57
1 Answers
1
alter table t
add column i serial primary key;
https://www.postgresql.org/docs/current/static/sql-altertable.html

Clodoaldo Neto
- 118,695
- 26
- 233
- 260