Received: from xyzzy.lan.internal (d226-84-103.home.cgocable.net [24.226.84.103]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1CHeIE13969 for ; Tue, 12 Feb 2002 12:40:18 -0500 (EST) (envelope-from drew@xyzzy.dhs.org) Received: from drew by xyzzy.lan.internal with local (Exim 3.33 #1 (Debian)) id 16aguY-0008KD-00; Tue, 12 Feb 2002 12:40:10 -0500 Date: Tue, 12 Feb 2002 12:40:10 -0500 To: Jean-Max Reymond Cc: pgsql-sql@postgresql.org Subject: Re: SQL request to retrieve the type of columns Message-ID: <20020212174010.GA31935@xyzzy.dhs.org> References: <3C6938B3.3060208@bull.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline In-Reply-To: <3C6938B3.3060208@bull.net> User-Agent: Mutt/1.3.27i From: "Andrew G. Hammond" X-Fnord: +++ath X-WebTV-Stationery: Standard; BGColor=black; TextColor=black X-Message-Flag: Message text blocked: ANTI-MICROSOFT OPINIONS X-BeenThere: drew@xyzzy.dhs.org X-Archive-Number: 200202/135 X-Sequence-Number: 6563 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 12, 2002 at 04:45:55PM +0100, Jean-Max Reymond wrote: > I am looking for a SQL request (must be executed in a ECPG program) to > retrieve the type of each column in a Postgres table. >=20 > For example, > \d wapi > Table "wapi" > Attribute | Type | Modifier=20 > ------------+-----------------------+---------- > wapinom | character(8) |=20 > wapicall | character varying(12) |=20 > wapitrans | character varying(4) |=20 > wapistruct | character varying(50) |=20 =46rom the psql man page section on variables: ECHO_HIDDEN When this variable is set and a backslash command queries the database, the query is first shown. This way you can study the Postgres internals and provide similar functionality in your own programs. If you set the variable to the value ``noexec'', the queries are just shown but are not actually sent to the backend and executed. \set ECHO_HIDDEN CREATE TABLE foo (foo_id SERIAL PRIMARY KEY, name TEXT NOT NULL ); \d foo Table "foo" Attribute | Type | Modifier -----------+---------+---------------------------------------------------- foo_id | integer | not null default nextval('"foo_foo_id_seq"'::text) name | text | not null Index: foo_pkey --=20 Andrew G. Hammond mailto:drew@xyzzy.dhs.org http://xyzzy.dhs.org/~dre= w/ 56 2A 54 EF 19 C0 3B 43 72 69 5B E3 69 5B A1 1F 613-389-54= 81 5CD3 62B0 254B DEB1 86E0 8959 093E F70A B457 84B1 "To blow recursion you must first blow recur" -- me --3V7upXqbjpZ4EhLz Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjxpU3oACgkQCT73CrRXhLFtkgCff5OrtUL8x/xVe3MjFFhCOMSv MYsAoIoY2aaho2ScxRwWnY+QuOR8b7yN =CQ/S -----END PGP SIGNATURE----- --3V7upXqbjpZ4EhLz--