querying sequence names

From: David Kerr <dmk(at)mr-paradox(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: querying sequence names
Date: 2009-04-14 20:16:56
Message-ID: 20090414201656.GC13876@mr-paradox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I like to keep a "grants" script around that will fix all of the
permissions in my enviornments (I've got heavy development going on so
i'm frequently dropping and recreating an environment, or duplicating
the schema elsewhere)

finding a list of sequences that i could build dynamic sql off of was a
nightmare. I ended up creating a view based on the pg_tables view.

CREATE OR REPLACE VIEW pg_sequences AS
SELECT n.nspname AS schemaname, c.relname AS sequencename,
pg_get_userbyid(c.relowner) AS sequenceowner, t.spcname AS "tablespace",
c.relhasindex AS hasindexes, c.relhasrules AS hasrules, c.reltriggers >
0 AS hastriggers
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
WHERE c.relkind = 'S'::"char";

(basically changed 'r' to 'S')

so my question is - is there a better way to handle this?

Thanks!

Dave Kerr

Browse pgsql-general by date

  From Date Subject
Next Message Kynn Jones 2009-04-14 20:19:42 Re: 'no pg_hba.conf entry for host "[local]", user "postgres", database "postgres"'...
Previous Message benoît carpentier 2009-04-14 19:50:20 Benetl, a free ETL tool for files using postgreSQL, is out in version 2.7