From matthias.seiferth@ipk.fhg.de Mon May 10 15:28:28 1999 Received: from mail2.zrz.tu-berlin.de (mail2.zrz.TU-Berlin.DE [130.149.4.14]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA40218 for ; Mon, 10 May 1999 11:28:28 -0400 (EDT) (envelope-from matthias.seiferth@ipk.fhg.de) Received: from cetus.zrz.tu-berlin.de ([130.149.5.114] helo=sp.zrz.TU-Berlin.DE) by mail2.zrz.tu-berlin.de with smtp (EXIM-2.12) for id 10gryS-0003ph-00; Mon, 10 May 1999 17:28:08 +0200 Received: from mattigjf by sp.zrz.TU-Berlin.DE (SMI-8.6/ZRZ-Sol-2.5) id RAA26844; Mon, 10 May 1999 17:28:07 +0200 Message-ID: <000e01be9af8$ff1fe5c0$0100a8c0@mattigjf> From: "Matthias Seiferth" To: Subject: Retrieving column names and table names of a database Date: Mon, 10 May 1999 17:23:02 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000B_01BE9B09.C22B9680" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 This is a multi-part message in MIME format. ------=_NextPart_000_000B_01BE9B09.C22B9680 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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=B4t know if there is something similar in SQL or if = there is a function I can call.=20 Please reply even if there is no function =20 Thanks in advance for your help Matthias .=20 ------=_NextPart_000_000B_01BE9B09.C22B9680 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
, this may sound stupid, but is there a = way of=20 retrieving the table names and column names of a database using = SQL. I know=20 there is \d in psql, but I don=B4t know if there is something similar in = SQL or if=20 there is a function I can call.
Please reply even if there is no function
 
Thanks in advance for your = help
 
Matthias
. =
------=_NextPart_000_000B_01BE9B09.C22B9680-- From nourry@ensinfo.univ-nantes.fr Tue May 18 12:59:05 1999 Received: from dec1.ensinfo.univ-nantes.fr (dec1.ensinfo.sciences.univ-nantes.fr [193.52.100.2]) by hub.org (8.9.3/8.9.3) with ESMTP id IAA27747 for ; Tue, 18 May 1999 08:59:05 -0400 (EDT) (envelope-from nourry@ensinfo.univ-nantes.fr) Received: from pcfred.ensinfo.sciences.univ-nantes.fr (IDENT:nourry@pcfred.ensinfo.sciences.univ-nantes.fr [193.52.100.233]) by dec1.ensinfo.univ-nantes.fr (8.9.3/jtpda-5.3.1) with SMTP id OAA03376 for pgsql-sql@postgresql.org; Tue, 18 May 1999 14:52:41 +0200 (MET DST) Date: Tue, 18 May 1999 14:52:41 +0200 (MET DST) From: nourry@ensinfo.univ-nantes.fr (Frederic Nourry) Message-Id: <199905181252.OAA03376@dec1.ensinfo.univ-nantes.fr> To: pgsql-sql@postgresql.org Subject: Re: Retrieving column names and table names of a database MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit >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 //data/base/ . Sorry for my english !