Re: newbie needs help with postgres internal tables - Mailing list pgsql-general

From Dave Smith
Subject Re: newbie needs help with postgres internal tables
Date
Msg-id 3BFE8533.3020604@candata.com
Whole thread Raw
In response to newbie needs help with postgres internal tables  (William WAISSE <wwaisse@esprit-equipe.fr>)
List pgsql-general
My suggestion would be to run psql with the -E option. This will display
the commands it uses to get it's info.

William WAISSE wrote:

>  Hi, everybody.
>
>  This is my first post on this list and I hope It's the good place for my
> question.
>
>  I'm developping an Opensource projetc which aims to be a GTK
> frontend for Postgresql first ( and other DB later ), whose name will be
> GPF ( GPF is not a Postgresql Frontend ).
>
>  So I need to use mysef tables like pg_class, pg_attribute, pgdatabase.
>
>  By now, I need two things :
>
> 1- Find all the fields that belongs to a particular table.
>
>   It was difficult to find the good fiels but I found this query, which seems
> to be good for me.
>
> select attname
> from pg_attribute a
> where a.attnum>0
>    and
>          a.attrelid= ( select oid
>                             from pg_class c
>                             where c.relname='gpf_db') ;
>
>  ( 'gpf_db' is the name of the database I'm searching all the fattributes )
>  ( Is ther a better way to do this )
>
>  does a documentation exists concerning postgres internals, which I
> havren't found, and which would say something like
> "the relation between pg_class and pg_attribute is the field
> oid in in pg_class which is the same as the field attrelid in  pg_attribute"
> "attnum in pg_attribute is >0 for 'user' fields and <0 for internal fields"
> . . .
>
>  ( In fact I would need a map of all the relations between all the internal
> tables in postgres ;- ))
>
>
> 1- Find all the tables that belong to a particular database.
>
>  I have not been able to find an ID in pg_table or pg_class which
> would help me finding all the tables that belong to a particular database.
>  the only thing I could do is selecting on the field tableowner
> BUT
>  a user can have more than one database and all the tables of all the
> databases owned by this user will have the same tableowner.
>
> PS : sorry if my english is not always the best, I'm French ;-)
>
>



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Solaris 8 ./confgure problem.
Next
From: Tom Lane
Date:
Subject: Re: newbie needs help with postgres internal tables