Last active
September 16, 2022 21:04
-
-
Save israelss/a73f941b40834c1775f57dfc1c5c0e12 to your computer and use it in GitHub Desktop.
Reset and fill Postgres id sequence
This file contains hidden or 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
-- Reset sequence to 1 | |
ALTER SEQUENCE table_name_id_seq RESTART WITH 1; | |
-- Fill all entries with sequence | |
UPDATE table_name SET id=DEFAULT; | |
-- Ref: https://stackoverflow.com/questions/4678110/how-to-reset-sequence-in-postgres-and-fill-id-column-with-new-data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment