-
-
Save rtplv/040d48344ebfe847fceca877727261d9 to your computer and use it in GitHub Desktop.
How to reset ID column of a PostgreSQL table to let auto incrementation begin from 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
# See your sequence name inside psql console with \ds command. | |
ALTER SEQUENCE seq RESTART WITH 1; | |
# Update sequence | |
UPDATE table_name SET id=nextval('seq'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment