I need to apply a unique constraint to a
TEXT field which may or may not already contain duplicate values. If for instance I have
ABC twice, I don't mind renaming them as
ABC-2, but what if I already had
ABC-1 as an entry? Seems like a bit of an recursive problem. I probably need to do this through a cursor, selecting all duplicate rows and updating them one by one.
Does anyone have a snippet to share? I'm using PostgreSQL 9.4 and