Fw: Re: Is there no "DESCRIBE ;" on PGSQL? help!!! Поиск
Список
Период
Сортировка
От David Eduardo Gomez Noguera
Тема Fw: Re: Is there no "DESCRIBE ;" on PGSQL? help!!!
Дата
Msg-id 20011019082812.2bf29485.davidgn@servidor.unam.mx
обсуждение исходный текст
Ответы Re: Fw: Re: Is there no "DESCRIBE ;" on PGSQL? help!!!  (David Eduardo Gomez Noguera <davidgn@servidor.unam.mx>)
Список pgsql-hackers
----------  Forwarded message ----------
Date: Fri, 19 Oct 2001 08:22:46 -0600
From: David Eduardo Gomez Noguera <davidgn@servidor.unam.mx>
To: "Ron de Jong" <Ron.Antispam@news.tht.net>
Cc: davidgn@servidor.unam.mx
Subject: Re: [HACKERS] Is there no  "DESCRIBE <TABLE>;" on PGSQL?      help!!!

on psql, do \?  there are a lot of commands that let you do it:

\l   (this list databases)
dabicho=# \l        List of databases Database   |  Owner   | Encoding  
-------------+----------+-----------agenda      | dabicho  | SQL_ASCIIcele        | dabicho  | SQL_ASCIIdabicho     |
dabicho | SQL_ASCIIdiccionario | dabicho  | SQL_ASCIIimagenes    | dabicho  | SQL_ASCIIlibros      | dabicho  |
SQL_ASCIImp3        | dabicho  | SQL_ASCIIpostgres    | postgres | SQL_ASCIItemplate0   | postgres | SQL_ASCIItemplate1
 | postgres | SQL_ASCII
 
(10 rows)

mp3=# \d    (this list tables on the current db)         List of relations     Name      |   Type   |  Owner  
----------------+----------+---------album          | table    | dabichoalbum_id_seq   | sequence | dabichoartista
 | table    | dabichoartista_id_seq | sequence | dabichodirpath        | table    | dabichodirpath_id_seq | sequence |
dabichogenero        | table    | dabichogenero_id_seq  | sequence | dabichomp3            | table    |
dabichomp3_id_seq    | sequence | dabichopga_forms      | table    | dabichopga_layout     | table    |
dabichopga_queries   | table    | dabichopga_reports    | table    | dabichopga_schema     | table    |
dabichopga_scripts   | table    | dabicho
 


mp3=# \d mp3  (this describes a table (mp3)                                   Table "mp3"  Attribute   |       Type
  |                    Modifier                    
 
---------------+-------------------+------------------------------------------------id            | integer           |
notnull default nextval('"mp3_id_seq"'::text)fk_dirpath_id | integer           | not nullfilename      | character
varying| not nulltitulo        | text              | not null default 'unknown'fk_artista_id | integer           | not
nulldefault 1fk_album_id   | integer           | not null default 1comentario    | text              | not null default
'none'year         | integer           | default 2001genero        | smallint          | not null default 1
 
Indices: mp3_fk_dirpath_id_key,        mp3_pkey

with \pset you can set output format.

mp3=# \pset expanded
Expanded display is on.
mp3=# \d mp3
Table "mp3"
-[ RECORD 1 ]---------------------------------------------
Attribute | id
Type      | integer
Modifier  | not null default nextval('"mp3_id_seq"'::text)
-[ RECORD 2 ]---------------------------------------------
Attribute | fk_dirpath_id
Type      | integer
Modifier  | not null
-[ RECORD 3 ]---------------------------------------------
....
there are many combinations
mp3=# \pset border 2
Border style is 2.
mp3=# \d mp3                                    Table "mp3"
+---------------+-------------------+------------------------------------------------+
|   Attribute   |       Type        |                    Modifier                    |
+---------------+-------------------+------------------------------------------------+
| id            | integer           | not null default nextval('"mp3_id_seq"'::text) |
| fk_dirpath_id | integer           | not null                                       |
| filename      | character varying | not null                                       |
| titulo        | text              | not null default 'unknown'                     |
| fk_artista_id | integer           | not null default 1                             |
| fk_album_id   | integer           | not null default 1                             |
| comentario    | text              | not null default 'none'                        |
| year          | integer           | default 2001                                   |
| genero        | smallint          | not null default 1                             |
+---------------+-------------------+------------------------------------------------+
Indices: mp3_fk_dirpath_id_key,        mp3_pkey

pretty much the same, and fairly human readable to me. (although not everything sorted in columns, i guess you could do
querysto the system tables to get that, or use awk to get the bits you want =) )
 
I just this the postgres team has don an excelent work so far.

Reply.
> Any idea to get a human readable list with column descriptions like
> type,size,key,default,null.
> It would be nice if it would look simular to the mysql variant:
> 
> mysql> describe employee;
> +-----------+----------+------+-----+---------+----------------+
> | Field     | Type     | Null | Key | Default | Extra          |
> +-----------+----------+------+-----+---------+----------------+
> | Id        | int(11)  |      | PRI | NULL    | auto_increment |
> | FirstName | char(30) |      | MUL |         |                |
> | LastName  | char(30) |      |     |         |                |
> | Infix     | char(10) | YES  |     | NULL    |                |
> | Address1  | char(30) | YES  |     | NULL    |                |
> | PostCode  | char(10) | YES  |     | NULL    |                |
> | Town      | int(11)  | YES  |     | NULL    |                |
> +-----------+----------+------+-----+---------+----------------+
> 
> Cheers, Ron.
> 
> 
> 



-- 
ICQ: 15605359 Bicho                                 =^..^=
First, they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Gandhi.
........Por que no pensaran los hombres como los animales? Pink Panther........
-------------------------------気検体の一致------------------------------------
暑さ寒さも彼岸まで。
アン アン アン とっても大好き

> on psql, do \?  there are a lot of commands that let you do it:
> 
> \l   (this list databases)
> dabicho=# \l
>          List of databases
>   Database   |  Owner   | Encoding  
> -------------+----------+-----------
>  agenda      | dabicho  | SQL_ASCII
>  cele        | dabicho  | SQL_ASCII
>  dabicho     | dabicho  | SQL_ASCII
>  diccionario | dabicho  | SQL_ASCII
>  imagenes    | dabicho  | SQL_ASCII
>  libros      | dabicho  | SQL_ASCII
>  mp3         | dabicho  | SQL_ASCII
>  postgres    | postgres | SQL_ASCII
>  template0   | postgres | SQL_ASCII
>  template1   | postgres | SQL_ASCII
> (10 rows)
> 
> mp3=# \d    (this list tables on the current db)
>           List of relations
>       Name      |   Type   |  Owner  
> ----------------+----------+---------
>  album          | table    | dabicho
>  album_id_seq   | sequence | dabicho
>  artista        | table    | dabicho
>  artista_id_seq | sequence | dabicho
>  dirpath        | table    | dabicho
>  dirpath_id_seq | sequence | dabicho
>  genero         | table    | dabicho
>  genero_id_seq  | sequence | dabicho
>  mp3            | table    | dabicho
>  mp3_id_seq     | sequence | dabicho
>  pga_forms      | table    | dabicho
>  pga_layout     | table    | dabicho
>  pga_queries    | table    | dabicho
>  pga_reports    | table    | dabicho
>  pga_schema     | table    | dabicho
>  pga_scripts    | table    | dabicho
> 
> 
> mp3=# \d mp3  (this describes a table (mp3)
>                                     Table "mp3"
>    Attribute   |       Type        |                    Modifier                    
> ---------------+-------------------+------------------------------------------------
>  id            | integer           | not null default nextval('"mp3_id_seq"'::text)
>  fk_dirpath_id | integer           | not null
>  filename      | character varying | not null
>  titulo        | text              | not null default 'unknown'
>  fk_artista_id | integer           | not null default 1
>  fk_album_id   | integer           | not null default 1
>  comentario    | text              | not null default 'none'
>  year          | integer           | default 2001
>  genero        | smallint          | not null default 1
> Indices: mp3_fk_dirpath_id_key,
>          mp3_pkey
> 
> with \pset you can set output format.
> 
> mp3=# \pset expanded
> Expanded display is on.
> mp3=# \d mp3
> Table "mp3"
> -[ RECORD 1 ]---------------------------------------------
> Attribute | id
> Type      | integer
> Modifier  | not null default nextval('"mp3_id_seq"'::text)
> -[ RECORD 2 ]---------------------------------------------
> Attribute | fk_dirpath_id
> Type      | integer
> Modifier  | not null
> -[ RECORD 3 ]---------------------------------------------
> ....
> there are many combinations
> mp3=# \pset border 2
> Border style is 2.
> mp3=# \d mp3
>                                      Table "mp3"
> +---------------+-------------------+------------------------------------------------+
> |   Attribute   |       Type        |                    Modifier                    |
> +---------------+-------------------+------------------------------------------------+
> | id            | integer           | not null default nextval('"mp3_id_seq"'::text) |
> | fk_dirpath_id | integer           | not null                                       |
> | filename      | character varying | not null                                       |
> | titulo        | text              | not null default 'unknown'                     |
> | fk_artista_id | integer           | not null default 1                             |
> | fk_album_id   | integer           | not null default 1                             |
> | comentario    | text              | not null default 'none'                        |
> | year          | integer           | default 2001                                   |
> | genero        | smallint          | not null default 1                             |
> +---------------+-------------------+------------------------------------------------+
> Indices: mp3_fk_dirpath_id_key,
>          mp3_pkey
> 
> pretty much the same, and fairly human readable to me. (although not everything sorted in columns, i guess you could
doquerys to the system tables to get that, or use awk to get the bits you want =) )
 
> I just this the postgres team has don an excelent work so far.
> 
> Reply.
> > Any idea to get a human readable list with column descriptions like
> > type,size,key,default,null.
> > It would be nice if it would look simular to the mysql variant:
> > 
> > mysql> describe employee;
> > +-----------+----------+------+-----+---------+----------------+
> > | Field     | Type     | Null | Key | Default | Extra          |
> > +-----------+----------+------+-----+---------+----------------+
> > | Id        | int(11)  |      | PRI | NULL    | auto_increment |
> > | FirstName | char(30) |      | MUL |         |                |
> > | LastName  | char(30) |      |     |         |                |
> > | Infix     | char(10) | YES  |     | NULL    |                |
> > | Address1  | char(30) | YES  |     | NULL    |                |
> > | PostCode  | char(10) | YES  |     | NULL    |                |
> > | Town      | int(11)  | YES  |     | NULL    |                |
> > +-----------+----------+------+-----+---------+----------------+
> > 
> > Cheers, Ron.
> > 
> > 
> > 
> 
> 
> 
> -- 
> ICQ: 15605359 Bicho
>                                   =^..^=
> First, they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Gandhi.
> ........Por que no pensaran los hombres como los animales? Pink Panther........
> -------------------------------気検体の一致------------------------------------
> 暑さ寒さも彼岸まで。
> アン アン アン とっても大好き


-- 
ICQ: 15605359 Bicho                                 =^..^=
First, they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Gandhi.
........Por que no pensaran los hombres como los animales? Pink Panther........
-------------------------------気検体の一致------------------------------------
暑さ寒さも彼岸まで。
アン アン アン とっても大好き



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pg_sorttemp files
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Does "postmaster -i"...