Received: from ara.zf.jcu.cz (ara.zf.jcu.cz [160.217.161.4]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f26Fbgx17040; Tue, 6 Mar 2001 10:37:43 -0500 (EST) (envelope-from zakkr@zf.jcu.cz) Received: (from zakkr@localhost) by ara.zf.jcu.cz (8.9.3/8.9.3/Debian 8.9.3-21) id QAA03179; Tue, 6 Mar 2001 16:37:33 +0100 Date: Tue, 6 Mar 2001 16:37:32 +0100 From: Karel Zak To: Boulat Khakimov Cc: Karel Zak , pgsql-sql@postgresql.org, pgsql-general@postgresql.org Subject: Re: Re: MySQLs Describe emulator! Message-ID: <20010306163732.E13152@ara.zf.jcu.cz> References: <3AA44897.121D60F0@inet-interactif.com> <3764.983846777@sss.pgh.pa.us> <3AA4F0DE.D96BA904@inet-interactif.com> <20010306155522.B13152@ara.zf.jcu.cz> <3AA4FFF1.5875B665@inet-interactif.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.0.1i In-Reply-To: <3AA4FFF1.5875B665@inet-interactif.com>; from boulat@inet-interactif.com on Tue, Mar 06, 2001 at 10:19:13AM -0500 X-Archive-Number: 200103/250 X-Sequence-Number: 5731 On Tue, Mar 06, 2001 at 10:19:13AM -0500, Boulat Khakimov wrote: > > Karel Zak wrote: > > > On Tue, Mar 06, 2001 at 09:14:54AM -0500, Boulat Khakimov wrote: > > > Tom Lane wrote: > > > > > > > > Boulat Khakimov writes: > > > > > Here is a nifty query I came up with > > > > > that provides a detailed information on any row of any table. > > > > > Something that is build into mySQL (DESC tablename fieldname) > > > > > but not into PG. > > > > > > > > Er, what's wrong with psql's "\d table" ? > > > > > > 2) as a programmer I need to be able to find out as much info as > > > possible about any given field > > > which is what "describe" for in mySQL. > > > > As a programmer you can see psql source and directly found how SQL > > query execute this tool. The PostgreSQL needn't non-standard statements > > like MySQL's SHOW, DESC -- the postgreSQL has system catalogs. > > > > Karel > > Agreed! Why make someones life easier?? > Let's complicate things as much as possible that way it's more > fun,right? ;o) > > Dont understand how this works? No problem -- just read the source > code. > Dont understand how to get that to work? Not a problem -- read the > source code! > > The only problem tho, the source codes tend to be thousands of lines > when it comes > to DBs and time is ... Well man, I not write this code, but I need 1 minute for found it.... see src/bin/psql/describe.c: SELECT a.attname, format_type(a.atttypid, a.atttypmod), attnotnull, a.atthasdef, a.attnum, obj_description(a.oid) FROM pg_class c, pg_attribute a WHERE c.relname = 'YourTableName' AND ^^^^^^^^^^^^^ a.attnum > 0 AND a.attrelid = c.oid ORDER BY a.attnum; If I good remenber anywhere in PG's docs is catalog schema. It isn't too much difficult write queries like above-mentioned, because catalog attributes/tables names are intuitive. For start see pg_class and pg_attribute. Karel -- Karel Zak http://home.zf.jcu.cz/~zakkr/ C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz