Skip to content

Instantly share code, notes, and snippets.

View ygorlazaro's full-sized avatar
👨‍💻
Making something incredible (https://hashnode.com/@ygorlazaro)

Ygor Lazaro ygorlazaro

👨‍💻
Making something incredible (https://hashnode.com/@ygorlazaro)
View GitHub Profile
@ygorlazaro
ygorlazaro / reset.sql
Created October 26, 2020 23:09 — forked from tbarbugli/reset.sql
reset all sequences on a postgres db
SELECT 'SELECT SETVAL(' ||quote_literal(S.relname)|| ', MAX(' ||quote_ident(C.attname)|| ') ) FROM ' ||quote_ident(T.relname)|| ';'
FROM pg_class AS S, pg_depend AS D, pg_class AS T, pg_attribute AS C
WHERE S.relkind = 'S'
AND S.oid = D.objid
AND D.refobjid = T.oid
AND D.refobjid = C.attrelid
AND D.refobjsubid = C.attnum
ORDER BY S.relname;