Skip to content

Instantly share code, notes, and snippets.

@MbuguaCaleb
Last active February 21, 2022 08:50
Show Gist options
  • Save MbuguaCaleb/62a9c0cf2411c9319694da5fc24cd95c to your computer and use it in GitHub Desktop.
Save MbuguaCaleb/62a9c0cf2411c9319694da5fc24cd95c to your computer and use it in GitHub Desktop.
SET search_path TO unittrust;
ALTER SEQUENCE um_counties_id_seq RESTART WITH 1
CREATE SEQUENCE um_banks_id_seq START 1;
@MbuguaCaleb
Copy link
Author

https://gist.github.com/henriquemenezes/962829815e8e7875f5f4376133b2f209

-- Get Max ID from table
SELECT MAX(id) FROM table;

-- Get Next ID from table
SELECT nextval('table_id_seq');

-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));

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