Skip to content

Commit

Permalink
fix postgres sequences snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
Lance Caraccioli committed Apr 11, 2012
1 parent 38a5d4f commit 8930305
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fix-sequences.sql
@@ -0,0 +1,4 @@
--running this script will generate sql which will fix broken sequences for a postgres database... (tested on postgres 8.4)

select 'SELECT setval('''||ns.nspname||'.'||cs.relname||''', max("'||attname||'")) FROM "'||ns.nspname||'"."'||c.relname||'";' from pg_class c, pg_class cs, pg_attribute a, pg_attrdef d, pg_namespace ns where c.relnamespace = ns.oid and cs.relkind = 'S' and d.adsrc ~ cs.relname and c.oid = a.attrelid and c.oid = d.adrelid and d.adnum = a.attnum;

0 comments on commit 8930305

Please sign in to comment.