How to fix all duplicate key values from sequences?
1
vote
2
answers
15166
views
I have a Postgres database that I created with a Django application. When I transferred it over, it never reindexed anything and it gives me errors trying to do this. It seems as if there are lots of tables that have this issue. Is there a way I can use this code that I found on another question and use it for all sequences and tables?
SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1)
Asked by Lewis Menelaws
(111 rep)
Dec 19, 2017, 09:52 PM
Last activity: Mar 6, 2022, 01:13 AM
Last activity: Mar 6, 2022, 01:13 AM