Re: Insert a description while creating a table

From: luiz(at)klais(dot)com(dot)br
To: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Insert a description while creating a table
Date: 2003-08-13 13:05:26
Message-ID: Pine.LNX.4.44.0308131000330.2124-100000@elessar.klais
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)klais(dot)com(dot)br *
*************************

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Reinoud van Leeuwen 2003-08-13 13:11:27 Re: Insert a description while creating a table
Previous Message Christoph Haller 2003-08-13 12:54:59 Re: Insert a description while creating a table