-1

I have a table with data that has no unique data anywhere on the table. I want to create a column that would serve as a unique identifier.

How do I add a new primary key column to the existing table?

JoeJam
  • 371
  • 1
  • 14
  • 1
    Index and primary key syntax is readily available on Google and other Stack Overflow posts. A primary key is a unique value in the table. If you don't have a unique ID on the table anywhere, you can't use a primary key. – dfundako Mar 14 '18 at 17:08
  • https://stackoverflow.com/questions/787722/postgresql-autoincrement – Jacob H Mar 14 '18 at 17:14
  • That is precisely my question. How do I create a column that can be used as a primary key? – JoeJam Mar 15 '18 at 13:54

1 Answers1

0

You can use the following SQL statement to create a unique identifier (Primiry Key) in to your existing table.

ALTER TABLE your_table ADD  key_column SERIAL;
JoeJam
  • 371
  • 1
  • 14
Zulfiqar Ali
  • 121
  • 6