[英]postgresql psql command \d does not list indexes
我使用以下命令在 PGSQL(版本 13)中創建了一個表:
db1=# create table temp2(
foo int PRIMARY KEY,
bar varchar(20) UNIQUE NOT NULL
);
CREATE TABLE
\d
或d+
命令不列出表的關聯索引(與我從閱讀各種站點收集到的相反。)
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 | |
有沒有辦法獲取與表關聯的列表索引?
謝謝你,艾哈邁德。
您將tuples_only
設置為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)
通過執行以下操作進行驗證:
\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
您需要 \di 來獲取索引信息。 查看手冊:
字母E、i、m、s、t、v分別代表外部表、索引、物化視圖、序列、表和視圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.