Re: newbie needs help with postgres internal tables

From: Dave Smith <dave(at)candata(dot)com>
To: William WAISSE <wwaisse(at)esprit-equipe(dot)fr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: newbie needs help with postgres internal tables
Date: 2001-11-23 17:19:47
Message-ID: 3BFE8533.3020604@candata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 ;-)
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-11-23 17:23:48 Re: newbie needs help with postgres internal tables
Previous Message Tom Lane 2001-11-23 16:56:40 Re: Solaris 8 ./confgure problem.