Description field for tables and views

Started by Kent Dorfmanalmost 2 years ago6 messagesgeneral
Jump to latest
#1Kent Dorfman
kent.dorfman766@gmail.com

I think I already know the answer but asking here is probably quicker
turnaround than researching it.

I've gotten into a "view bloat" scenario with many many custom views
that I cannot remember what they actually do.  Is there any psql
function/command to add a description field to a table or view
definition in the system?  Would be nice to have a one line general text
note capability to quickly see what a complicated view does when looking
at the defintion via
# \dv+

Looks like the command has the field present, but not sure how to
populate it.

am using PostgreSQL 13.xx in Debian.

#2Christophe Pettus
xof@thebuild.com
In reply to: Kent Dorfman (#1)
Re: Description field for tables and views

On Jul 3, 2024, at 12:28, Kent Dorfman <kent.dorfman766@gmail.com> wrote:

Is there any psql function/command to add a description field to a table or view definition in the system?

Allow me to introduce you to my good friend "COMMENT":

https://www.postgresql.org/docs/current/sql-comment.html

#3Guyren Howe
guyren@gmail.com
In reply to: Kent Dorfman (#1)
Re: Description field for tables and views

Comment is probably what you’re looking for.

If you don’t want to use that: it’s a database. Make a table. Put whatever information in there that you need.

Either look up by view name, or schema + view name, or oid: https://www.postgresql.org/docs/current/datatype-oid.html

Show quoted text

On Jul 3, 2024, at 12:28, Kent Dorfman <kent.dorfman766@gmail.com> wrote:

I think I already know the answer but asking here is probably quicker turnaround than researching it.

I've gotten into a "view bloat" scenario with many many custom views that I cannot remember what they actually do. Is there any psql function/command to add a description field to a table or view definition in the system? Would be nice to have a one line general text note capability to quickly see what a complicated view does when looking at the defintion via
# \dv+

Looks like the command has the field present, but not sure how to populate it.

am using PostgreSQL 13.xx in Debian.

#4Achilleas Mantzios
a.mantzios@cloud.gatewaynet.com
In reply to: Kent Dorfman (#1)
Re: Description field for tables and views

Στις 3/7/24 22:28, ο/η Kent Dorfman έγραψε:

I think I already know the answer but asking here is probably quicker
turnaround than researching it.

I've gotten into a "view bloat" scenario with many many custom views
that I cannot remember what they actually do.  Is there any psql
function/command to add a description field to a table or view
definition in the system?  Would be nice to have a one line general
text note capability to quickly see what a complicated view does when
looking at the defintion via
# \dv+

Looks like the command has the field present, but not sure how to
populate it.

am using PostgreSQL 13.xx in Debian.

In addition to the COMMENT advised by PostgreSQL friends above, you
might put your schema into some version control system, such as git, so
you can have all the info : why something was added/changed, by whom,
what for, etc.

--
Achilleas Mantzios
IT DEV - HEAD
IT DEPT
Dynacom Tankers Mgmt (as agents only)

#5Kent Dorfman
kent.dorfman766@gmail.com
In reply to: Christophe Pettus (#2)
Re: Description field for tables and views

On 7/3/24 15:30, Christophe Pettus wrote:

On Jul 3, 2024, at 12:28, Kent Dorfman<kent.dorfman766@gmail.com> wrote:

Is there any psql function/command to add a description field to a table or view definition in the system?

Allow me to introduce you to my good friend "COMMENT":

https://www.postgresql.org/docs/current/sql-comment.html

Thanks for the hint!

It's the simplest and most direct solution.  Been typing SQL for 40
years and haven't had occasion to use COMMENT.  Is it SQL standard or
postgres specific?  Am not a DBA by trade but an embedded systems guy.

#6Christophe Pettus
xof@thebuild.com
In reply to: Kent Dorfman (#5)
Re: Description field for tables and views

On Jul 3, 2024, at 13:24, Kent Dorfman <kent.dorfman766@gmail.com> wrote:
Is it SQL standard or postgres specific?

It's not in the SQL standard (at the bottom of each page for each SQL command is a note regarding its relationship with the SQL standard). Other DBMS implement something similar, however.