Skip to content

Instantly share code, notes, and snippets.

View tarkhil's full-sized avatar

Alexander Povolotsky tarkhil

View GitHub Profile
@tarkhil
tarkhil / fixseq.sql
Created January 25, 2024 07:55
Fix all sequences in postgres
-- Accidently, I've got and restored a dump without proper sequence values
SELECT concat('SELECT set', left(substr(column_default, 5),-1),', (select max(', column_name,') from ', table_schema, '.', table_name, ')+1);') FROM information_schema.columns where column_default like 'nextval%';
-- just save it into SQL and run