try starting psql with the -E option -- this displays all queries used
internally to the screen, i.e.:

bash-2.04$ psql -E
********* QUERY *********
SELECT usesuper FROM pg_user WHERE usename = 'mfork'
*************************

Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

mfork=# \d test
********* QUERY *********
SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules
FROM pg_class WHERE relname='test'
*************************

********* QUERY *********
SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull,
a.atthasdef, a.attnum
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = 'test'
  AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
ORDER BY a.attnum
*************************

        Table "test"
 Attribute | Type | Modifier 
-----------+------+----------
 t         | text | 
 d         | date | 


So to get the info displayed with \d, execute the query:

SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull,
a.atthasdef, a.attnum
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = '<<TABLE NAME>>' 
  AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
ORDER BY a.attnum


Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

On Tue, 6 Mar 2001, Boulat Khakimov wrote:

> Hi,
> 
> 1) "\d table" can only be used in psql, you cant run a query like that
> using libpq for example
> 
> 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.
> 
> Regards,
> Boulat Khakimov
>       
> 
> -- 
> Nothing Like the Sun
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
> 


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Reply via email to