Re: Insert a description while creating a table - Mailing list pgsql-sql

From Christoph Haller
Subject Re: Insert a description while creating a table
Date
Msg-id 3F3A3523.4261096@rodos.fzk.de
Whole thread Raw
In response to Insert a description while creating a table  (luiz@klais.com.br)
Responses Re: Insert a description while creating a table
Re: Insert a description while creating a table
List pgsql-sql
> > 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 descriptionsSchema | 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 whereobjoid = (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




pgsql-sql by date:

Previous
From: BenLaKnet
Date:
Subject: Re: Insert a description while creating a table
Next
From: luiz@klais.com.br
Date:
Subject: Re: Insert a description while creating a table