Skip to content

Instantly share code, notes, and snippets.

@mobilestack
Last active August 14, 2018 21:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mobilestack/8789844 to your computer and use it in GitHub Desktop.
Save mobilestack/8789844 to your computer and use it in GitHub Desktop.
postgresql id_seq reset

SELECT MAX(id) FROM your_table; SELECT nextval('your_table_id_seq'); SELECT setval('your_table_id_seq', (SELECT MAX(id) FROM your_table));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment