Skip to content

Instantly share code, notes, and snippets.

View boatcoder's full-sized avatar

Mark Jones boatcoder

View GitHub Profile
@henriquemenezes
henriquemenezes / postgresql-set-id-seq.sql
Created March 31, 2016 12:23
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- 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));