From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | psql \d for wide tables / pattern for individual columns |
Date: | 2019-11-10 21:29:28 |
Message-ID: | 20191110212928.GQ4999@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
We have some very wide tables (historically, up to 1600 columns ; this is
improved now, but sometimes still several hundred, with numerous pages output
to psql pager). Is is reasonable to suggest adding a psql command to show a
table's definition, without all the columns listed?
Or limit display to matching columns ? That's more general than the above
functionality, if "empty string" is taken to mean "show no columns", like \d
table "" or \d table *id or \d table ????
Attached minimal patch for the latter.
postgres=# \d pg_attribute ""
Table "pg_catalog.pg_attribute"
Column | Type | Collation | Nullable | Default
--------+------+-----------+----------+---------
Indexes:
"pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
"pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
postgres=# \d pg_attribute "attn*|attrel*"
Table "pg_catalog.pg_attribute"
Column | Type | Collation | Nullable | Default
------------+----------+-----------+----------+---------
attrelid | oid | | not null |
attname | name | | not null |
attnum | smallint | | not null |
attndims | integer | | not null |
attnotnull | boolean | | not null |
Indexes:
"pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
"pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
postgres=# \d pg_attribute ??????
Table "pg_catalog.pg_attribute"
Column | Type | Collation | Nullable | Default
--------+-----------+-----------+----------+---------
attlen | smallint | | not null |
attnum | smallint | | not null |
attacl | aclitem[] | | |
Indexes:
"pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
"pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
postgres=# \d pg_attribute *id
Table "pg_catalog.pg_attribute"
Column | Type | Collation | Nullable | Default
----------+------+-----------+----------+---------
attrelid | oid | | not null |
atttypid | oid | | not null |
Indexes:
"pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
"pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
Attachment | Content-Type | Size |
---|---|---|
v1-0001-psql-Allow-filtering-columns-shown-by-d.patch | text/x-diff | 4.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2019-11-10 22:26:09 | Re: pg_upgrade fails to detect unsupported arrays and ranges |
Previous Message | Tomas Vondra | 2019-11-10 21:18:32 | Re: Index Skip Scan |