Re: Help with creating Documentation

Lists: pgsql-novice
From: WejofOST(at)aol(dot)com
To: pgsql-novice(at)postgresql(dot)org
Subject: Help with creating Documentation
Date: 2007-03-05 20:04:24
Message-ID: d69.34ac35d.331e1818@aol.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

I have inherited a pgsql database and a raft of PHP programs.
I am a "novice" as far as pgsql is concerned although as a mainframe
dinosaur I have knowledge of a number of RDBS systems plus MS-SQL and MySQL .
The PHP code is quite readable but on the database side the previous owner
did not believe in documentation!

How can I generate a list of tables and then fields within the tables in
pgsql?

I have looked in the documentation indexes but unable to see mention of such
facilities?

Wej Parry
OST Ltd. UK.


From: joseph speigle <joesp(at)sirfsup(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Help with creating Documentation
Date: 2007-03-09 01:06:12
Message-ID: 20070309010612.GB9460@www.sirfsup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

>
> How can I generate a list of tables and then fields within the tables in
> pgsql?
>

log into psql on the commandline.
the command you want is

\dt

will show all tables

\d table_name

will show you fields

http://www.sirfsup.com/sql_servers/postgresql/pg_utilities.htm#psql

--
joe speigle
http://combali.co.kr


From: joseph speigle <joesp(at)sirfsup(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Help with creating Documentation
Date: 2007-03-09 02:31:57
Message-ID: 20070309023157.GA3365@www.sirfsup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

> I have inherited a pgsql database and a raft of PHP programs.
> I am a "novice" as far as pgsql is concerned although as a mainframe
> dinosaur I have knowledge of a number of RDBS systems plus MS-SQL and MySQL .
> The PHP code is quite readable but on the database side the previous owner
> did not believe in documentation!
>
> How can I generate a list of tables and then fields within the tables in
> pgsql?
>

maybe you just want to dump all the DDL at one time
@localhost] pg_dump db_name > db_name.txt

--
joe speigle
www.sirfsup.com


From: "Ashish Karalkar" <ashish(dot)karalkar(at)info-spectrum(dot)com>
To: "joseph speigle" <joesp(at)sirfsup(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Help with creating Documentation
Date: 2007-03-09 12:59:19
Message-ID: 00bd01c7624a$c4c698c0$170211ac@LIONKING.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

You can also query the database information schema to get the list of table
and there columns

select table_name,column_name,
case when character_maximum_length is null then data_type else
data_type||'('||character_maximum_length||')'end as Datatype_Length,case
when is_nullable='YES' then '' else ' NOT NULL ' end as Constraints1
from information_schema.columns where table_schema='public' order by
table_name,ordinal_position

----- Original Message -----
From: "joseph speigle" <joesp(at)sirfsup(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Sent: Friday, March 09, 2007 8:01 AM
Subject: Re: [NOVICE] Help with creating Documentation

>> I have inherited a pgsql database and a raft of PHP programs.
>> I am a "novice" as far as pgsql is concerned although as a mainframe
>> dinosaur I have knowledge of a number of RDBS systems plus MS-SQL and
>> MySQL .
>> The PHP code is quite readable but on the database side the previous
>> owner
>> did not believe in documentation!
>>
>> How can I generate a list of tables and then fields within the tables in
>> pgsql?
>>
>
> maybe you just want to dump all the DDL at one time
> @localhost] pg_dump db_name > db_name.txt
>
> --
> joe speigle
> www.sirfsup.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate


From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Help with creating Documentation
Date: 2007-03-09 14:45:50
Message-ID: 20070309144550.GA23704@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Fri, Mar 09, 2007 at 11:31:57 +0900,
joseph speigle <joesp(at)sirfsup(dot)com> wrote:
> > I have inherited a pgsql database and a raft of PHP programs.
> > I am a "novice" as far as pgsql is concerned although as a mainframe
> > dinosaur I have knowledge of a number of RDBS systems plus MS-SQL and MySQL .
> > The PHP code is quite readable but on the database side the previous owner
> > did not believe in documentation!
> >
> > How can I generate a list of tables and then fields within the tables in
> > pgsql?
> >
>
> maybe you just want to dump all the DDL at one time
> @localhost] pg_dump db_name > db_name.txt

You probably want to use the -s so you only get the DDL.

You can also read up on the information schema and the catalogs, if you
want to make queries to look for specific things.