Обсуждение: Adding notes against fields

Поиск
Список
Период
Сортировка

Adding notes against fields

От
Oliver Helm
Дата:
Hello,

I was wondering if if is possible to add a note against a field on a postgresql table?  

For example when running "\d tablename" i would like to have and additional column called 'notes' which i could add to by altering the table.  As the note would be field specific, not row specific i would rather not have to do it with an additional column in the table!

I have tried searching though the documentation, but so far have no found anything.  Can anyone suggest whether this is in fact possible, and point me in the right direction?

Many Thanks!

- Oliver



Re: Adding notes against fields

От
Richard Huxton
Дата:
Oliver Helm wrote:
> Hello,
>
> I was wondering if if is possible to add a note against a field on a
> postgresql table?

You can add comments: COMMENT ON <various things> IS 'text' - see
manuals for details.

--
   Richard Huxton
   Archonet Ltd

Re: Adding notes against fields

От
"Joshua D. Drake"
Дата:
On Thu, 24 Apr 2008 19:04:34 +0100
Richard Huxton <dev@archonet.com> wrote:

> Oliver Helm wrote:
> > Hello,
> >
> > I was wondering if if is possible to add a note against a field on
> > a postgresql table?
>
> You can add comments: COMMENT ON <various things> IS 'text' - see
> manuals for details.
>

However, COMMENTS don't append.

Joshua D. Drake

--
The PostgreSQL Company since 1997: http://www.commandprompt.com/
PostgreSQL Community Conference: http://www.postgresqlconference.org/
United States PostgreSQL Association: http://www.postgresql.us/
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate



Re: Adding notes against fields

От
Alvaro Herrera
Дата:
Joshua D. Drake wrote:
> On Thu, 24 Apr 2008 19:04:34 +0100
> Richard Huxton <dev@archonet.com> wrote:
>
> > Oliver Helm wrote:
> > > Hello,
> > >
> > > I was wondering if if is possible to add a note against a field on
> > > a postgresql table?
> >
> > You can add comments: COMMENT ON <various things> IS 'text' - see
> > manuals for details.
>
> However, COMMENTS don't append.

But you can add one to the new column.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Re: Adding notes against fields

От
Chris Browne
Дата:
oliver@blue-emu.net (Oliver Helm) writes:

> Hello,
>
>
>
> I was wondering if if is possible to add a note against a field on a postgresql table?  
>
>
>
> For example when running "\d tablename" i would like to have and additional column called 'notes' which i could add
toby altering the table.  As the note would 
> be field specific, not row specific i would rather not have to do it with an additional column in the table!
>
>
>
> I have tried searching though the documentation, but so far have no found anything.  Can anyone suggest whether this
is infact possible, and point me in the right 
> direction?

Have you taken a look at the COMMENT statement?

test@[local]:5432=# \h comment
Command:     COMMENT
Description: define or change the comment of an object
Syntax:
COMMENT ON
{
  TABLE object_name |
  COLUMN table_name.column_name |
  AGGREGATE agg_name (agg_type [, ...] ) |
  CAST (sourcetype AS targettype) |
  CONSTRAINT constraint_name ON table_name |
  CONVERSION object_name |
  DATABASE object_name |
  DOMAIN object_name |
  FUNCTION func_name ( [ [ argmode ] [ argname ] argtype [, ...] ] ) |
  INDEX object_name |
  LARGE OBJECT large_object_oid |
  OPERATOR op (leftoperand_type, rightoperand_type) |
  OPERATOR CLASS object_name USING index_method |
  [ PROCEDURAL ] LANGUAGE object_name |
  ROLE object_name |
  RULE rule_name ON table_name |
  SCHEMA object_name |
  SEQUENCE object_name |
  TABLESPACE object_name |
  TRIGGER trigger_name ON table_name |
  TYPE object_name |
  VIEW object_name
} IS 'text'

--
let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;;
http://www3.sympatico.ca/cbbrowne/sap.html
"Much of this software was user-friendly, meaning that it was intended
for users who did not know anything about computers, and furthermore
had absolutely no intention whatsoever of learning."
-- A. S. Tanenbaum, "Modern Operating Systems, ch 1.2.4"