postgresql 如何列出为 postgres 中的表创建的索引
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37329561/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to list indexes created for table in postgres
提问by klin
Could you tell me how to check what indexes are created for some table in postgresql ?
你能告诉我如何检查在 postgresql 中为某个表创建了哪些索引吗?
回答by klin
The view pg_indexesprovides access to useful information about each index in the database, eg.
视图pg_indexes提供对有关数据库中每个索引的有用信息的访问,例如。
select *
from pg_indexes
where tablename not like 'pg%';
回答by dwilkins
if you're in psql, then:
如果你在 psql 中,那么:
\d tablename
show Indexes, Foreign Keys and references...
显示索引、外键和引用...
回答by b.vishnu Prasad
You can use this query:
您可以使用此查询:
select tablename,indexname,tablespace,indexdef from pg_indexes where tablename = 'your_table_name'
;
select tablename,indexname,tablespace,indexdef from pg_indexes where tablename = 'your_table_name'
;
where has tablenameis a field in pg_indexes,you an get an accurate indices by matching user defined table at 'your_table_name' at WHEREclause . This will give you the desired details.
其中表名是pg_indexes 中的一个字段,您可以通过在WHERE子句中匹配用户定义的表“ your_table_name”来获得准确的索引。这将为您提供所需的详细信息。