Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 4659D2E0048 for ; Sun, 20 Apr 2008 21:34:04 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 05618-01 for ; Sun, 20 Apr 2008 21:34:01 -0300 (ADT) X-Greylist: delayed 00:19:57.556037 by SQLgrey-1.7.5 Received: from dukecmmtai02.coxmail.com (dukecmmtai02.coxmail.com [68.99.120.72]) by developer.postgresql.org (Postfix) with ESMTP id 774002E0051 for ; Sun, 20 Apr 2008 21:34:01 -0300 (ADT) Received: from [127.0.0.1] (really [70.166.0.90]) by dukecmmtar02.coxmail.com (InterMail vM.6.01.06.01 201-2131-130-101-20060113) with ESMTP id <20080421001359.ELRN13126.dukecmmtar02.coxmail.com@[127.0.0.1]>; Sun, 20 Apr 2008 20:13:59 -0400 Message-ID: <480BDC4B.9010104@acm.org> Date: Sun, 20 Apr 2008 17:14:03 -0700 From: TJ O'Donnell User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: cbbrowne@acm.org, pgsql-sql@postgresql.org Subject: Re: Desc Commnad in pgsql? References: <20080420182009.56E5F8F0AE0@maia-1.hub.org> In-Reply-To: <20080420182009.56E5F8F0AE0@maia-1.hub.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/120 X-Sequence-Number: 30659 I like the table and other info from psql and find I sometimes need that info in my client programs. Are there any SQL/plpgsql functions that are analogous to the psql \dt, \ds, etc. commands? For example create function d_table(table_name text) returns setof record that could be used in SQL commands in client programs? I am not concerned whether these are compatible with other RDBMS. TJ O'Donnell http://www.gnova.com > > If you're looking for ways to "describe" a table, there are two > mechanisms: > > 1. SQL standard (probably SQL:1993) describes an > "information_schema" which contains tables or views that allow > querying database metadata in a fairly standard fashion. > > PostgreSQL supports that. > > 2. Probably easier and friendlier, albeit nonportable, is to use > the psql "\d" command. > > >> >> For instance: >> \dt will list all tables >> \ds will list all sequences >> \dv will list all views >> and there's a further cast of ~20 variants for various different sorts >> of objects.