pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Insert a description while creating a table
8+ messages / 6 participants
[nested] [flat]

* Insert a description while creating a table
@ 2003-08-13 11:56  luiz@klais.com.br
  0 siblings, 1 reply; 8+ messages in thread

From: luiz@klais.com.br @ 2003-08-13 11:56 UTC (permalink / raw)
  To: pgsql-sql

Hi,

I want to insert descriptions at the columns of my tables but without 
using the command COMMENT ON. I want to do it together with the table 
creation. Is that possible?

I wanna do something like this:

create table test (
	id serial 'Descripitions about ID',
	name varchar(50) 'Descriptions about NAME'
);

Thanks in advance


Luiz.

-- 
*************************
*  Luiz Fernando Pinto  *
*          -*-          *
* Klais Desenvolvimento *
*   luiz@klais.com.br   *
*************************




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Insert a description while creating a table
@ 2003-08-13 12:06  Rod Taylor <rbt@rbt.ca>
  parent: luiz@klais.com.br
  0 siblings, 2 replies; 8+ messages in thread

From: Rod Taylor @ 2003-08-13 12:06 UTC (permalink / raw)
  To: luiz@klais.com.br; +Cc: pgsql-sql

On Wed, 2003-08-13 at 07:56, luiz@klais.com.br wrote:
> Hi,
> 
> I want to insert descriptions at the columns of my tables but without 
> using the command COMMENT ON. I want to do it together with the table 
> creation. Is that possible?
> 
> I wanna do something like this:
> 
> create table test (
> 	id serial 'Descripitions about ID',
> 	name varchar(50) 'Descriptions about NAME'
> );

Probably not going to happen in the backend.

However, you should be able to accomplish that with a little bit of Perl
to pre-process the SQL.

Attachments:

  signature.asc (application/pgp-signature, 186B) download

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Insert a description while creating a table
@ 2003-08-13 12:24  Benoît Bournon <benoit.bournon@adelis.com>
  parent: Rod Taylor <rbt@rbt.ca>
  1 sibling, 0 replies; 8+ messages in thread

From: Benoît Bournon @ 2003-08-13 12:24 UTC (permalink / raw)
  To: ; +Cc: pgsql-sql

comment on table "test"
is 'fziofeiozfiezojfezjfeziojfeziojf ezfjioezifj ezio' ;





Rod Taylor wrote:

>On Wed, 2003-08-13 at 07:56, luiz@klais.com.br wrote:
>  
>
>>Hi,
>>
>>I want to insert descriptions at the columns of my tables but without 
>>using the command COMMENT ON. I want to do it together with the table 
>>creation. Is that possible?
>>
>>I wanna do something like this:
>>
>>create table test (
>>	id serial 'Descripitions about ID',
>>	name varchar(50) 'Descriptions about NAME'
>>);
>>    
>>
>
>Probably not going to happen in the backend.
>
>However, you should be able to accomplish that with a little bit of Perl
>to pre-process the SQL.
>  
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Insert a description while creating a table
@ 2003-08-13 12:31  BenLaKnet <benlaknet@icqmail.com>
  parent: Rod Taylor <rbt@rbt.ca>
  1 sibling, 0 replies; 8+ messages in thread

From: BenLaKnet @ 2003-08-13 12:31 UTC (permalink / raw)
  To: Rod Taylor <rbt@rbt.ca>; +Cc: luiz@klais.com.br; pgsql-sql

create table test (
     id serial ,
     name varchar(50)
 );

 
 COMMENT ON TABLE "test"
IS 'MySQL table
id_training_form ... id_form_unique';

comment on COLUMN "test"."id"
is 'greigjreoigjreigjore iojrjiogre' ;


Doc postgresql comment


Rod Taylor wrote:

>On Wed, 2003-08-13 at 07:56, luiz@klais.com.br wrote:
>  
>
>>Hi,
>>
>>I want to insert descriptions at the columns of my tables but without 
>>using the command COMMENT ON. I want to do it together with the table 
>>creation. Is that possible?
>>
>>I wanna do something like this:
>>
>>create table test (
>>	id serial 'Descripitions about ID',
>>	name varchar(50) 'Descriptions about NAME'
>>);
>>    
>>
>
>Probably not going to happen in the backend.
>
>However, you should be able to accomplish that with a little bit of Perl
>to pre-process the SQL.
>  
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Insert a description while creating a table
@ 2003-08-13 12:54  Christoph Haller <ch@rodos.fzk.de>
  0 siblings, 2 replies; 8+ messages in thread

From: Christoph Haller @ 2003-08-13 12:54 UTC (permalink / raw)
  To: pgsql-sql; luiz@klais.com.br

> > I want to insert descriptions at the columns of my tables but
without
> > using the command COMMENT ON. I want to do it together with the
table
> > creation. Is that possible?
> >
> > I wanna do something like this:
> >
> > create table test (
> >     id serial 'Descripitions about ID',
> >     name varchar(50) 'Descriptions about NAME'
> > );
>
> Probably not going to happen in the backend.
>
> However, you should be able to accomplish that with a little bit of
Perl
> to pre-process the SQL.
>
That perl script comes to my mind too.
The reason why Luiz doesn't like it, may be because you can't
see these descriptions within psql using \dd test

I did
the create table, then
COMMENT ON COLUMN test.id is 'Descripitions about ID';
COMMENT ON COLUMN test.name is 'Descriptions about NAME';
\dd test shows

         Object descriptions
 Schema | Name | Object | Description
--------+------+--------+-------------
(0 rows)

This is odd. OK, I know the doc says
\dd [ pattern ]

    Shows the descriptions of objects matching the pattern, or of all
visible objects if no argument is given. But in either case,
    only objects that have a description are listed. ("Object" covers
aggregates, functions, operators, types, relations (tables, views,
    indexes, sequences, large objects), rules, and triggers.) For
example:

Nothing about columns.
But what is the purpose of comments on columns if you can only get them
via
select * from pg_description where
 objoid = (select typrelid from pg_type where typname='test')
 order by objsubid ;
 objoid | classoid | objsubid |       description
--------+----------+----------+-------------------------
  17326 |     1259 |        1 | Descripitions about ID
  17326 |     1259 |        2 | Descriptions about NAME
(2 rows)

which you'll have to find out on your own.

Regards, Christoph





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Insert a description while creating a table
@ 2003-08-13 13:05  luiz@klais.com.br
  parent: Christoph Haller <ch@rodos.fzk.de>
  1 sibling, 0 replies; 8+ messages in thread

From: luiz@klais.com.br @ 2003-08-13 13:05 UTC (permalink / raw)
  To: Christoph Haller <ch@rodos.fzk.de>; +Cc: pgsql-sql

Hi Christoph,

I'm thinking that the best solution is create a script in perl or 
python that executes de COMMENT command to me. My initial idea would be 
comment my columns in a standard way and then run the script.

My comment that will turn into description will start with 
"/*$" instead of the simple "/*", for instance.

Regards,

Luiz.

On Wed, 13 Aug 2003, Christoph Haller wrote:

> > > I want to insert descriptions at the columns of my tables but
> without
> > > using the command COMMENT ON. I want to do it together with the
> table
> > > creation. Is that possible?
> > >
> > > I wanna do something like this:
> > >
> > > create table test (
> > >     id serial 'Descripitions about ID',
> > >     name varchar(50) 'Descriptions about NAME'
> > > );
> >
> > Probably not going to happen in the backend.
> >
> > However, you should be able to accomplish that with a little bit of
> Perl
> > to pre-process the SQL.
> >
> That perl script comes to my mind too.
> The reason why Luiz doesn't like it, may be because you can't
> see these descriptions within psql using \dd test
> 
> I did
> the create table, then
> COMMENT ON COLUMN test.id is 'Descripitions about ID';
> COMMENT ON COLUMN test.name is 'Descriptions about NAME';
> \dd test shows
> 
>          Object descriptions
>  Schema | Name | Object | Description
> --------+------+--------+-------------
> (0 rows)
> 
> This is odd. OK, I know the doc says
> \dd [ pattern ]
> 
>     Shows the descriptions of objects matching the pattern, or of all
> visible objects if no argument is given. But in either case,
>     only objects that have a description are listed. ("Object" covers
> aggregates, functions, operators, types, relations (tables, views,
>     indexes, sequences, large objects), rules, and triggers.) For
> example:
> 
> Nothing about columns.
> But what is the purpose of comments on columns if you can only get them
> via
> select * from pg_description where
>  objoid = (select typrelid from pg_type where typname='test')
>  order by objsubid ;
>  objoid | classoid | objsubid |       description
> --------+----------+----------+-------------------------
>   17326 |     1259 |        1 | Descripitions about ID
>   17326 |     1259 |        2 | Descriptions about NAME
> (2 rows)
> 
> which you'll have to find out on your own.
> 
> Regards, Christoph
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 
> 

-- 
*************************
*  Luiz Fernando Pinto  *
*          -*-          *
* Klais Desenvolvimento *
*   luiz@klais.com.br   *
*************************




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Insert a description while creating a table
@ 2003-08-13 13:11  Reinoud van Leeuwen <reinoud.v@n.leeuwen.net>
  parent: Christoph Haller <ch@rodos.fzk.de>
  1 sibling, 0 replies; 8+ messages in thread

From: Reinoud van Leeuwen @ 2003-08-13 13:11 UTC (permalink / raw)
  To: pgsql-sql

On Wed, Aug 13, 2003 at 02:54:59PM +0200, Christoph Haller wrote:
> \dd test shows
> 
>          Object descriptions
>  Schema | Name | Object | Description
> --------+------+--------+-------------
> (0 rows)
> 
> This is odd. OK, I know the doc says
> \dd [ pattern ]
> 
>     Shows the descriptions of objects matching the pattern, or of all
> visible objects if no argument is given. But in either case,
>     only objects that have a description are listed. ("Object" covers
> aggregates, functions, operators, types, relations (tables, views,
>     indexes, sequences, large objects), rules, and triggers.) For
> example:
> 
> Nothing about columns.
> But what is the purpose of comments on columns if you can only get them
> via
> select * from pg_description where

Have you tried \d+ tablename? (sorry for the long lines ";-)

drbob=# \dd object
                            Object descriptions
 Schema |  Name  | Object |                   Description
--------+--------+--------+-------------------------------------------------
 public | object | table  | The table that holds all instances of objects.
(1 row)

drbob=# \d+ object
                                                                                                          
Table "public.object"
      Column      |            Type             |                  
Modifiers                   |                                                               
Description
------------------+-----------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------
 id               | integer                     | not null default 
nextval('shared_ids'::text) | (global) unique ID for this table
 object_def_id    | integer                     | not null                                     
| foreign key to object_def.id
 name             | character varying(60)       |                                              
| natural name of this object
 superobject_id   | integer                     |                                              
| foreign key to object.id. This field is only filled in when the this 
object is a subobject of another object (EG a port in a router)
 subobject_def_id | integer                     |                                              
| foreign key to subobject_def.id. This field is only filled in when this 
object is a subobject of another object (EG a port in a router)
 has_subobject    | boolean                     | not null default 'FALSE'                     
| boolean indicating that this object instance has subobjects (EG router 
that has ports)
 date_added       | timestamp without time zone |                                              
| date this record was added to the database
 user_added       | character varying(20)       |                                              
| username that added this record to the database
 date_changed     | timestamp without time zone |                                              
| date this record was last changed
 user_changed     | character varying(20)       |                                              
| username that made the last change to this record
Indexes: pk_object primary key btree (id),
         object_pk unique btree (id),
         object_object_def_fk btree (object_def_id),
         object_object_fk btree (superobject_id),
         object_subobject_def_fk btree (subobject_def_id)
Triggers: tdb_object,
          tiua_object,
          tiub_object
-- 
__________________________________________________
"Nothing is as subjective as reality"
Reinoud van Leeuwen    reinoud.v@n.leeuwen.net
http://www.xs4all.nl/~reinoud
__________________________________________________



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Insert a description while creating a table
@ 2003-08-13 13:23  Christoph Haller <ch@rodos.fzk.de>
  0 siblings, 0 replies; 8+ messages in thread

From: Christoph Haller @ 2003-08-13 13:23 UTC (permalink / raw)
  To: pgsql-sql

> On Wed, Aug 13, 2003 at 02:54:59PM +0200, Christoph Haller wrote:
> > \dd test shows
> >
> >          Object descriptions
> >  Schema | Name | Object | Description
> > --------+------+--------+-------------
> > (0 rows)
> >
> > This is odd. OK, I know the doc says
> > \dd [ pattern ]
> >
> >     Shows the descriptions of objects matching the pattern, or of
all
> > visible objects if no argument is given. But in either case,
> >     only objects that have a description are listed. ("Object"
covers
> > aggregates, functions, operators, types, relations (tables, views,
> >     indexes, sequences, large objects), rules, and triggers.) For
> > example:
> >
> > Nothing about columns.
> > But what is the purpose of comments on columns if you can only get
them
> > via
> > select * from pg_description where
>
> Have you tried \d+ tablename? (sorry for the long lines ";-)
>
I apologize for complaining, missed that completely.
Thanks to Reinoud for pointing this out.

Regards, Christoph







^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2003-08-13 13:23 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-08-13 11:56 Insert a description while creating a table luiz@klais.com.br
2003-08-13 12:06 ` Rod Taylor <rbt@rbt.ca>
2003-08-13 12:24   ` Benoît Bournon <benoit.bournon@adelis.com>
2003-08-13 12:31   ` BenLaKnet <benlaknet@icqmail.com>
2003-08-13 12:54 Re: Insert a description while creating a table Christoph Haller <ch@rodos.fzk.de>
2003-08-13 13:05 ` luiz@klais.com.br
2003-08-13 13:11 ` Reinoud van Leeuwen <reinoud.v@n.leeuwen.net>
2003-08-13 13:23 Re: Insert a description while creating a table Christoph Haller <ch@rodos.fzk.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox