0

We did a mistake on our of the table creations in PostgreSql. We forgot to add "serial primary key" for one of the tables's columns called as rowid. Instead we just said "serial". As a result now we see duplicates for that table based on rowid. I understand I need to alter the table to include primary key. But how do I redo the duplicates rows? I do not think without fixing duplicated rows I can add the primary key constraint.

user2452057
  • 816
  • 2
  • 11
  • 23
  • 1
    I there any foreign keys to this table? – Abelisto Nov 27 '20 at 21:11
  • 2
    @Abelisto If there's no unique index, there can't be. – Bergi Nov 27 '20 at 21:16
  • 1
    Before fixing the table, fix the application that actually hardcoded the inserted values instead of relying on the generated `serial` default. Do you understand how you did arrive at the duplicate values? – Bergi Nov 27 '20 at 21:18
  • Have a look at https://stackoverflow.com/q/4358613/1048572 and in particular https://stackoverflow.com/a/40296406/1048572 – Bergi Nov 27 '20 at 21:23

0 Answers0