I created a table in PGSQL (version 13) using the following command:
db1=# create table temp2(
foo int PRIMARY KEY,
bar varchar(20) UNIQUE NOT NULL
);
CREATE TABLE
The \d
or d+
command does not list the associated indexes for the table (contrary to what I gathered from reading various sites.)
db1=# \d temp2
foo | integer | | not null |
bar | character varying(20) | | not null |
db1=# \d+ temp2
foo | integer | | not null | | plain | |
bar | character varying(20) | | not null | | extended | |
Is there a way I get list indexes associated with a table?
Thank you, Ahmed.
You have tuples_only
set to on
.
create table temp2(
foo int PRIMARY KEY,
bar varchar(20) UNIQUE NOT NULL
);
test(5432)=# \d temp2
Table "public.temp2"
Column | Type | Collation | Nullable | Default
--------+-----------------------+-----------+----------+---------
foo | integer | | not null |
bar | character varying(20) | | not null |
Indexes:
"temp2_pkey" PRIMARY KEY, btree (foo)
"temp2_bar_key" UNIQUE CONSTRAINT, btree (bar)
test(5432)=# \pset tuples_only on
test(5432)=# \d temp2
foo | integer | | not null |
bar | character varying(20) | | not null |
test(5432)=# \pset tuples_only off
test(5432)=# \d temp2
Table "public.temp2"
Column | Type | Collation | Nullable | Default
--------+-----------------------+-----------+----------+---------
foo | integer | | not null |
bar | character varying(20) | | not null |
Indexes:
"temp2_pkey" PRIMARY KEY, btree (foo)
"temp2_bar_key" UNIQUE CONSTRAINT, btree (bar)
Verify by doing:
\pset
border 1
columns 0
csv_fieldsep ','
expanded off
fieldsep '|'
fieldsep_zero off
footer on
format aligned
linestyle ascii
null 'NULL'
numericlocale off
pager 1
pager_min_lines 0
recordsep '\n'
recordsep_zero off
tableattr
title
tuples_only on
unicode_border_linestyle single
unicode_column_linestyle single
unicode_header_linestyle single