SELECT 'SELECT setval('''|| c.relname ||''', (SELECT max(id) FROM '|| replace(c.relname, '_id_seq', '') ||'));' FROM pg_class c WHERE c.relkind = 'S' and relname like '%_id_seq';
