X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AC5115323C for ; Sun, 24 Apr 2005 15:53:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48004-05 for ; Sun, 24 Apr 2005 18:53:20 +0000 (GMT) Received: from relay.snowman.net (relay.snowman.net [66.92.160.56]) by svr1.postgresql.org (Postfix) with ESMTP id D74B353D5B for ; Sun, 24 Apr 2005 15:53:00 -0300 (ADT) Received: from ns.snowman.net (ns.snowman.net [10.10.0.2]) by relay.snowman.net (8.13.1/8.13.1/Debian-19) with ESMTP id j3OIqmSP015834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 24 Apr 2005 14:52:48 -0400 Received: from ns.snowman.net (localhost [127.0.0.1]) by ns.snowman.net (8.13.1/8.13.1/Debian-19) with ESMTP id j3OIrPup014335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 24 Apr 2005 14:53:25 -0400 Received: (from sfrost@localhost) by ns.snowman.net (8.13.1/8.13.1/Submit) id j3OIrPI5014332; Sun, 24 Apr 2005 14:53:25 -0400 Date: Sun, 24 Apr 2005 14:53:25 -0400 From: Stephen Frost To: Alan Chandler Cc: pgsql-sql@postgresql.org Subject: Re: Matching the MYSQL "Describe " command Message-ID: <20050424185324.GD27470@ns.snowman.net> Mail-Followup-To: Alan Chandler , pgsql-sql@postgresql.org References: <200504241902.16770.alan@chandlerfamily.org.uk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="G4iJoqBmSsgzjUCe" Content-Disposition: inline In-Reply-To: <200504241902.16770.alan@chandlerfamily.org.uk> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/2.4.24ns.3.0 (i686) X-Uptime: 14:48:02 up 449 days, 13:38, 27 users, load average: 4.27, 4.26, 4.20 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/367 X-Sequence-Number: 21260 --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Alan Chandler (alan@chandlerfamily.org.uk) wrote: > I am rather new to Postgres (running 7.4) but I am trying to port some PH= P=20 > code that has been built to run with mysql. >=20 > I have got stuck trying to find the equivalent of the Mysql "DESCRIBE=20 > ;" SQL statement that lists the columns and type identifiers o= f a=20 > table. You might want to take a look at the schema called 'information_schema' and see if you can find what you want there. The only problem I have with that, currently anyway, is that it seems to only show things the current user owns as opposted to what the current user has access to, which seems a bit silly to me. > I think I am going to do a SELECT on the "pg_attribute" table, but I don'= t=20 > understand what the "attrelid" column of that table refers to. I need to= get=20 > the table name of the column so that I can restrict the select with a WHE= RE=20 > clause so I assumed it was a key into the pg_class table, but I can't see= a=20 > column in this table that could potentially correspond and therefore I co= uld=20 > join to it. In psql you can do: \set ECHO_HIDDEN 'yes' Then just run whatever psql \d or other command you want and it'll give you the queiries it used. Using information_schema should technically be more portable though, I believe. Stephen --G4iJoqBmSsgzjUCe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFCa+skrzgMPqB3kigRAsxHAJ9S9dOq7+9oB8P7u2t72oROXdcQnACglpgB MUGA+/GNPynuBOfaUwHVUXQ= =iur3 -----END PGP SIGNATURE----- --G4iJoqBmSsgzjUCe--