pg_indexes

一个列出当前数据库中可用索引的系统视图

pg_indexes 是一个列出当前数据库中可用索引的系统目录视图。

pg_indexes 添加于 PostgreSQL 6.4

按 PostgreSQL 版本定义

pg_indexes (PostgreSQL 17)

            View "pg_catalog.pg_indexes"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 tablename  | name |           |          | 
 indexname  | name |           |          | 
 tablespace | name |           |          | 
 indexdef   | text |           |          |
    

文档: pg_indexes

pg_indexes (PostgreSQL 16)

            View "pg_catalog.pg_indexes"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 tablename  | name |           |          | 
 indexname  | name |           |          | 
 tablespace | name |           |          | 
 indexdef   | text |           |          |
    

文档: pg_indexes

pg_indexes (PostgreSQL 15)

            View "pg_catalog.pg_indexes"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 tablename  | name |           |          | 
 indexname  | name |           |          | 
 tablespace | name |           |          | 
 indexdef   | text |           |          |
    

文档: pg_indexes

pg_indexes (PostgreSQL 14)

            View "pg_catalog.pg_indexes"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 tablename  | name |           |          | 
 indexname  | name |           |          | 
 tablespace | name |           |          | 
 indexdef   | text |           |          |
    

文档: pg_indexes

pg_indexes (PostgreSQL 13)

            View "pg_catalog.pg_indexes"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 tablename  | name |           |          | 
 indexname  | name |           |          | 
 tablespace | name |           |          | 
 indexdef   | text |           |          |
    

文档: pg_indexes

pg_indexes (PostgreSQL 12)

            View "pg_catalog.pg_indexes"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 tablename  | name |           |          | 
 indexname  | name |           |          | 
 tablespace | name |           |          | 
 indexdef   | text |           |          |
    

文档: pg_indexes

pg_indexes (PostgreSQL 11)

            View "pg_catalog.pg_indexes"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 tablename  | name |           |          | 
 indexname  | name |           |          | 
 tablespace | name |           |          | 
 indexdef   | text |           |          |
    

文档: pg_indexes

pg_indexes (PostgreSQL 10)

            View "pg_catalog.pg_indexes"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 tablename  | name |           |          | 
 indexname  | name |           |          | 
 tablespace | name |           |          | 
 indexdef   | text |           |          |
    

文档: pg_indexes

pg_indexes (PostgreSQL 9.6)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text |
    

文档: pg_indexes

pg_indexes (PostgreSQL 9.5)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text |
    

文档: pg_indexes

pg_indexes (PostgreSQL 9.4)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text |
    

文档: pg_indexes

pg_indexes (PostgreSQL 9.3)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text |
    

文档: pg_indexes

pg_indexes (PostgreSQL 9.2)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text |
    

文档: pg_indexes

pg_indexes (PostgreSQL 9.1)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text |
    

文档: pg_indexes

pg_indexes (PostgreSQL 9.0)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text |
    

文档: pg_indexes

pg_indexes (PostgreSQL 8.4)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text | 
View definition:
 SELECT n.nspname AS schemaname, c.relname AS tablename, i.relname AS indexname, t.spcname AS tablespace, pg_get_indexdef(i.oid) AS indexdef
   FROM pg_index x
   JOIN pg_class c ON c.oid = x.indrelid
   JOIN pg_class i ON i.oid = x.indexrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t ON t.oid = i.reltablespace
  WHERE c.relkind = 'r'::"char" AND i.relkind = 'i'::"char";
    

文档: pg_indexes

pg_indexes (PostgreSQL 8.3)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text | 
View definition:
 SELECT n.nspname AS schemaname, c.relname AS tablename, i.relname AS indexname, t.spcname AS tablespace, pg_get_indexdef(i.oid) AS indexdef
   FROM pg_index x
   JOIN pg_class c ON c.oid = x.indrelid
   JOIN pg_class i ON i.oid = x.indexrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t ON t.oid = i.reltablespace
  WHERE c.relkind = 'r'::"char" AND i.relkind = 'i'::"char";
    

文档: pg_indexes

pg_indexes (PostgreSQL 8.2)

 View "pg_catalog.pg_indexes"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 tablename  | name | 
 indexname  | name | 
 tablespace | name | 
 indexdef   | text | 
View definition:
 SELECT n.nspname AS schemaname, c.relname AS tablename, i.relname AS indexname, t.spcname AS "tablespace", pg_get_indexdef(i.oid) AS indexdef
   FROM pg_index x
   JOIN pg_class c ON c.oid = x.indrelid
   JOIN pg_class i ON i.oid = x.indexrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t ON t.oid = i.reltablespace
  WHERE c.relkind = 'r'::"char" AND i.relkind = 'i'::"char";
    

文档: pg_indexes

更改历史记录

示例

来自 pg_indexes 的示例行

postgres=# SELECT * FROM pg_indexes WHERE schemaname = 'public'\gx
-[ RECORD 1 ]-----------------------------------------------------------
schemaname | public
tablename  | foo
indexname  | foo_pkey
tablespace | 
indexdef   | CREATE UNIQUE INDEX foo_pkey ON public.foo USING btree (id)

分类

索引系统目录

另请参阅

pg_index

反馈

提交关于“pg_indexes”的任何评论、建议或更正 此处