Created
October 19, 2023 17:57
-
-
Save lbbedendo/54446caade2b50fda238aedc8213c3d7 to your computer and use it in GitHub Desktop.
Update PostgreSQL sequence with max(id) + 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT setval(pg_get_serial_sequence('table_name', 'id'), coalesce(max(id),0) + 1, false) FROM table_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment