pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Schema objects
3+ messages / 3 participants
[nested] [flat]

* Schema objects
@ 2007-10-09 20:04 Lucas Martino <lucas.martino@gmail.com>
  2007-10-09 20:58 ` Re: Schema objects Milen A. Radev <milen@radev.net>
  2007-10-10 02:54 ` Re: Schema objects Josh Trutwin <josh@trutwins.homeip.net>
  0 siblings, 2 replies; 3+ messages in thread

From: Lucas Martino @ 2007-10-09 20:04 UTC (permalink / raw)
  To: pgsql-admin

Hello,
   i need list all tables, functions, procedures, triggers, sequences of a
specific schema. How can i do this?

thanks

-- 
Lucas Martino
Argentina

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Schema objects
  2007-10-09 20:04 Schema objects Lucas Martino <lucas.martino@gmail.com>
@ 2007-10-09 20:58 ` Milen A. Radev <milen@radev.net>
  1 sibling, 0 replies; 3+ messages in thread

From: Milen A. Radev @ 2007-10-09 20:58 UTC (permalink / raw)
  To: pgsql-admin

Lucas Martino написа:
> Hello,
>    i need list all tables, functions, procedures, triggers, sequences of a
> specific schema. How can i do this?

One way (the only one I could think of) is to dump the schema using the
custom format and then use the pg_restore to list the contents of the
dump file:


pg_dump --format=c --schema=a_schema --schema-only --file=x.dump a_database

and then:

pg_restore --list x.dump


Probably someone would suggest a more direct way.


-- 
Milen A. Radev




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Schema objects
  2007-10-09 20:04 Schema objects Lucas Martino <lucas.martino@gmail.com>
@ 2007-10-10 02:54 ` Josh Trutwin <josh@trutwins.homeip.net>
  1 sibling, 0 replies; 3+ messages in thread

From: Josh Trutwin @ 2007-10-10 02:54 UTC (permalink / raw)
  To: pgsql-admin

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2007-10-10 02:54 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-10-09 20:04 Schema objects Lucas Martino <lucas.martino@gmail.com>
2007-10-09 20:58 ` Milen A. Radev <milen@radev.net>
2007-10-10 02:54 ` Josh Trutwin <josh@trutwins.homeip.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox