pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRetrieving column names and table names of a database
2+ messages / 2 participants
[nested] [flat]
* Retrieving column names and table names of a database
@ 1999-05-10 15:23 Matthias Seiferth <matthias.seiferth@ipk.fhg.de>
0 siblings, 0 replies; 2+ messages in thread
From: Matthias Seiferth @ 1999-05-10 15:23 UTC (permalink / raw)
To: pgsql-sql
Hi,
, this may sound stupid, but is there a way of retrieving the table names and column names of a database using SQL. I know there is \d in psql, but I don´t know if there is something similar in SQL or if there is a function I can call.
Please reply even if there is no function
Thanks in advance for your help
Matthias
.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Retrieving column names and table names of a database
@ 1999-05-18 12:52 Frederic Nourry <nourry@ensinfo.univ-nantes.fr>
0 siblings, 0 replies; 2+ messages in thread
From: nourry@ensinfo.univ-nantes.fr @ 1999-05-18 12:52 UTC (permalink / raw)
To: pgsql-sql
>Hi,
>, this may sound stupid, but is there a way of retrieving the table names and >column names of a database using SQL. I know there
>is \d in psql, but I don´t know if there is something similar in SQL or if there >is a function I can call.
>Please reply even if there is no function
>
>Thanks in advance for your help
>
>Matthias
>.
To retrieve the table names , use the pg_tables :
SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg_%';
To retrieve the column names , you can use the pg_attribute and
pg_type tables :
SELECT attname , typname FROM pg_attribute , pg_type WHERE
typrelid=attrelid AND typname = 'banals' ;
if your table name is 'banals' , but this will give you 6 columns that
you haven't declared : cmax,xmax,cmin,xmin,oid,ctid .
If you want column names with its type :
SELECT attname , opcname , atttypmod FROM pg_attribute,pg_type,
pg_opclass WHERE attrelid=typrelid AND atttypid=opcdeftype AND
typname = 'banals' ;
if your table name is 'banals' , but this will give the
column 'oid' you haven't declared
You can find all tables names in <where you put psql>//data/base/ .
Sorry for my english !
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-05-18 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-05-10 15:23 Retrieving column names and table names of a database Matthias Seiferth <matthias.seiferth@ipk.fhg.de>
1999-05-18 12:52 Re: Retrieving column names and table names of a database Frederic Nourry <nourry@ensinfo.univ-nantes.fr>
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