Re: DESCRIBE for composite type? - Mailing list pgsql-novice

From Richard Broersma
Subject Re: DESCRIBE for composite type?
Date
Msg-id 396486430810050813j7db2debawc649143306ad5ee7@mail.gmail.com
Whole thread Raw
In response to DESCRIBE for composite type?  ("Nikita Koselev" <koselev@gmail.com>)
List pgsql-novice
On Sat, Oct 4, 2008 at 11:54 PM, Nikita Koselev <koselev@gmail.com> wrote:

> How can I get description of this composite type later (field names
> and values)? Is there something in pgsql like DESCRIBE statement in
> oracle?

In the psql client, you simple called the client function \d
<functionname>.  Notice also, the queries that psql sends to the
PostgreSQL server inorder to produce the desired results.

testdb=# \d requirement_vo
********* 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 c.relname ~ '^(requirement_vo)$'
  AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 2, 3;
**************************

********* QUERY **********
SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules,
relhasoids , reltablespace
FROM pg_catalog.pg_class WHERE oid = '26098'
**************************

********* QUERY **********
SELECT a.attname,
  pg_catalog.format_type(a.atttypid, a.atttypmod),
  (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) 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 = '26098' AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
**************************

 Composite type "testschema.requirement_vo"
       Column        |         Type
---------------------+-----------------------
 name                | character varying(20)
 description         | character varying(20)
 requirement_id      | integer
 requirement_type_id | integer
 priority_id         | integer
 necessity_id        | integer
 lower_limit         | double precision
 upper_limit         | double precision

testdb=#


--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: array of composite types - how can I launch this function with an array of composite values
Next
From: "Ertel, Steve"
Date:
Subject: postgres launch os applications