Last active
July 29, 2019 14:23
-
-
Save ebouchut/0db0ed3a7d91fe502c510e48121d27cb to your computer and use it in GitHub Desktop.
Set SQL sequence
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
-- reset sequence to the max value of its ids | |
SELECT setval('public.mytable_id_seq', (SELECT MAX(id) FROM mytable)); | |
-- get the last value of a sequence | |
SELECT last_value FROM mytable_id_seq; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment