On Tue, 9 Oct 2007 17:04:35 -0300
"Lucas Martino" <lucas.martino@gmail.com> wrote:
> Hello,
> i need list all tables, functions, procedures, triggers,
> sequences of a specific schema. How can i do this?
I've always thought this syntax a little strange but:
\dt my_schema. (tables)
\df my_schema. (functions)
The period at the end is required.
For triggers there is no \ command (at least in 8.1) that I know of
so you can use a view I found somewhere - wish I could give proper
credit but can't remember where I found this.
I modified the original one to join in pg_namespace which allows you
to limit the view to show only triggers for a particular schema:
create view my_schema.showtriggers as
select trg.tgname as trigger_name, tbl.relname as table_name,
p.proname as function_name,
case trg.tgtype & cast(2 as int2)
when 0 then 'AFTER'
else 'BEFORE'
end as trigger_type,
case trg.tgtype & cast(28 as int2)
when 16 then 'UPDATE'
when 8 then 'DELETE'
when 4 then 'INSERT'
when 20 then 'INSERT, UPDATE'
when 28 then 'INSERT, UPDATE, DELETE'
when 24 then 'UPDATE, DELETE'
when 12 then 'INSERT, DELETE'
end as trigger_event
from pg_trigger trg, pg_class tbl, pg_proc p, pg_namespace nsp
where trg.tgrelid = tbl.oid
and trg.tgfoid = p.oid
and nsp.oid = tbl.relnamespace
and nsp.nspname = 'my_schema'
order by relname, trg.tgname;
Replace that line above "and nsp.nspname = 'my_schema'" to use your
schema name.
Josh