Re: Re: [GENERAL] MySQLs Describe emulator!

Поиск
Список
Период
Сортировка
От Michael Fork
Тема Re: Re: [GENERAL] MySQLs Describe emulator!
Дата
Msg-id Pine.BSI.4.21.0103061035440.17993-100000@glass.toledolink.com
обсуждение исходный текст
Ответ на Re: [GENERAL] MySQLs Describe emulator!  (Boulat Khakimov <boulat@inet-interactif.com>)
Ответы Re: Re: [GENERAL] MySQLs Describe emulator!  (Patrick Welche <prlw1@newn.cam.ac.uk>)
Список pgsql-sql
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 majordomo@postgresql.org
>


В списке pgsql-sql по дате отправления:

Предыдущее
От: Karel Zak
Дата:
Сообщение: Re: [GENERAL] Re: MySQLs Describe emulator!
Следующее
От: clayton cottingham
Дата:
Сообщение: Re: platform independend db access?