In our production state system we usually do this:
$ pg_dump -xacnDO database_name | grep "^SELECT setval "
This gives SQL statements which can be reloaded into an arbitrary
database. A bit slow, IMHO a clever select on the system tables should
give you the same result much faster.
HTH, Zoltan
-- Kov\'acs, Zolt\'an kovacsz@pc10.radnoti-szeged.sulinet.hu
http://www.math.u-szeged.hu/~kovzol ftp://pc10.radnoti-szeged.sulinet.hu/home/kovacsz