Created
April 16, 2013 18:51
-
-
Save alexeiramone/5398523 to your computer and use it in GitHub Desktop.
Postgresql id serial sequence default value restoration
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
ALTER TABLE {tablename} ALTER COLUMN id SET DEFAULT nextval('{tablename}_id_seq'::regclass); | |
-- replace {tablename} with the curly braces with the table name | |
-- the sequence name is generally in the form of {tablename}_id_seq but it can be anything, check in pgadmin its name | |
-- some softwares accidentaly delete this while doing some table operations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment