PostgreSQL学习手册(系统表)(四)
dclass
oidvector
pg_opclass.oid
对于构成索引键值的每个字段,这个字段都包含一个指向所使用的操作符表的OID。
indexprs
text
表达式树用于那些非简单字段引用的索引属性。它是一个列表,在indkey里面的每个零条目一个元素。如果所有索引属性都是简单的引用,则为空。
indpred
text
部分索引断言的表达式树。如果不是部分索引, 则是空字串。
见如下应用示例:
#查看该索引所在表的名称,以及构成该索引的键值数量和具体键值的字段编号。
postgres=# SELECT indnatts,indkey,relname FROM pg_index i, pg_class c WHERE c.relname = 'testtable2' AND indrelid = c.oid;
indnatts | indkey | relname www.2cto.com
----------+--------+------------
2 | 1 3 | testtable2
(1 row)
#查看指定表包含的索引,同时列出索引的名称。
postgres=# SELECT t.relname AS table_name, c.relname AS index_name FROM (SELECT relname,indexrelid FROM pg_index i, pg_class c WHERE c.relname = 'testtable2' AND indrelid = c.oid) t, pg_index i,pg_class c WHERE t.indexrelid = i.indexrelid AND i.indexrelid = c.oid;
table_name | index_name
------------+----------------
testtable2 | testtable2_idx
(1 row)
作者 Stephen_Liu