Skip to content

Instantly share code, notes, and snippets.

View wit3's full-sized avatar

Salvatore Scalzi wit3

  • Salsomaggiore Terme, Emilia Romagna, Italy
  • 19:37 (UTC +01:00)
  • X @_Wit3
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));