X-Original-To: pgsql-sql@postgresql.org Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by postgresql.org (Postfix) with ESMTP id 8EB9E475C3D for ; Thu, 13 Mar 2003 17:39:21 -0500 (EST) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.0.4) with ESMTP-TLS id 1663415; Thu, 13 Mar 2003 15:15:27 -0800 Message-ID: <3E710816.9060408@joeconway.com> Date: Thu, 13 Mar 2003 14:37:10 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: list@racistnames.com Cc: "PostgreSQL [SQL]" Subject: Re: Retrieving Definition for Composite Type References: <3E70DCBA.2060300@racistnames.com> In-Reply-To: <3E70DCBA.2060300@racistnames.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/345 X-Sequence-Number: 12384 Jordan S. Jones wrote: > Basically, I need the SQL equivalent of psql's "\d composite_type" Start psql with the -E option, and you can see all the internally generated queries. E.g (ex1_tup is a composite type): psql -E regression [snipped all the startup stuff] regression=# \d ex1_tup ********* QUERY ********** SELECT c.oid, n.nspname, c.relname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE pg_catalog.pg_table_is_visible(c.oid) AND c.relname ~ '^ex1_tup$' ORDER BY 2, 3; ************************** ********* QUERY ********** SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules FROM pg_catalog.pg_class WHERE oid = '1336877' ************************** ********* QUERY ********** SELECT a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod), (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef), a.attnotnull, a.attnum FROM pg_catalog.pg_attribute a WHERE a.attrelid = '1336877' AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum ************************** Composite type "public.ex1_tup" Column | Type ---------+------ relname | name colname | name HTH, Joe