Skip to content

Instantly share code, notes, and snippets.

@jpescada
Created January 29, 2021 15:30
Show Gist options
  • Select an option

  • Save jpescada/531c7b12571ce49c818e5cbdf627af0d to your computer and use it in GitHub Desktop.

Select an option

Save jpescada/531c7b12571ce49c818e5cbdf627af0d to your computer and use it in GitHub Desktop.
Reset PostgreSQL sequence key
SELECT setval(pg_get_serial_sequence('table_name_here', 'id'), COALESCE((SELECT MAX(id) + 1 FROM table_name_here), 1), false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment