Skip to content

Instantly share code, notes, and snippets.

@alexeiramone
Created April 16, 2013 18:51
Show Gist options
  • Save alexeiramone/5398523 to your computer and use it in GitHub Desktop.
Save alexeiramone/5398523 to your computer and use it in GitHub Desktop.
Postgresql id serial sequence default value restoration
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