Showing table comments with psql

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Showing table comments with psql

Mark Jeffcoat-2
I'm creating table and view comments with "COMMENT ON", and I can find
the comment in pg_description, but I can't find a way to show the
table comments using psql.

$ psql --version
psql (PostgreSQL) 11.1 (Debian 11.1-1+b2)

I'd expect to see table comments by using \d+, and found an old post
on this list where \dd worked; neither work for me today. Am I looking
in the right place? Is this a regression?

Thank you.


postgres=# create table test_table (col1 integer);
CREATE TABLE

postgres=# comment on table test_table is 'this is a table comment';
COMMENT

postgres=# \d+ test_table
                                Table "public.test_table"
 Column |  Type   | Collation | Nullable | Default | Storage | Stats
target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
 col1   | integer |           |          |         | plain   |              |

postgres=# \dd test_table
         Object descriptions
 Schema | Name | Object | Description
--------+------+--------+-------------
(0 rows)

postgres=# select * from pg_description where objoid = (select oid
from pg_class where relname = 'test_table');
 objoid | classoid | objsubid |       description
--------+----------+----------+-------------------------
 714760 |     1259 |        0 | this is a table comment
(1 row)

--
Mark Jeffcoat
Austin, TX

Reply | Threaded
Open this post in threaded view
|

Re: Showing table comments with psql

Pavel Stehule
Hi


pá 4. 1. 2019 v 17:57 odesílatel Mark Jeffcoat <[hidden email]> napsal:
I'm creating table and view comments with "COMMENT ON", and I can find
the comment in pg_description, but I can't find a way to show the
table comments using psql.

$ psql --version
psql (PostgreSQL) 11.1 (Debian 11.1-1+b2)

I'd expect to see table comments by using \d+, and found an old post
on this list where \dd worked; neither work for me today. Am I looking
in the right place? Is this a regression?

postgres=#  create table test_table (col1 integer);
CREATE TABLE
postgres=# comment on table test_table is 'this is a table comment';
COMMENT
postgres=# \dt+
                             List of relations
┌────────┬────────────┬───────┬───────┬─────────┬─────────────────────────┐
│ Schema │    Name    │ Type  │ Owner │  Size   │       Description       │
╞════════╪════════════╪═══════╪═══════╪═════════╪═════════════════════════╡
│ public │ test_table │ table │ pavel │ 0 bytes │ this is a table comment │
└────────┴────────────┴───────┴───────┴─────────┴─────────────────────────┘
(1 row)

postgres=#



Reply | Threaded
Open this post in threaded view
|

Re: Showing table comments with psql

Mark Jeffcoat
On Fri, Jan 4, 2019 at 11:00 AM Pavel Stehule <[hidden email]> wrote:

> postgres=#  create table test_table (col1 integer);
> CREATE TABLE
> postgres=# comment on table test_table is 'this is a table comment';
> COMMENT
> postgres=# \dt+
>                              List of relations
> ┌────────┬────────────┬───────┬───────┬─────────┬─────────────────────────┐
> │ Schema │    Name    │ Type  │ Owner │  Size   │       Description       │
> ╞════════╪════════════╪═══════╪═══════╪═════════╪═════════════════════════╡
> │ public │ test_table │ table │ pavel │ 0 bytes │ this is a table comment │
> └────────┴────────────┴───────┴───────┴─────────┴─────────────────────────┘
> (1 row)
>

I was so close! That works; thank you very much for your help, Pavel.

--
Mark Jeffcoat
Austin, TX