How to list indexes created for table in postgres

后端 未结 3 916
日久生厌
日久生厌 2021-02-01 11:37

Could you tell me how to check what indexes are created for some table in postgresql ?

相关标签:
3条回答
  • 2021-02-01 12:13

    The view pg_indexes provides access to useful information about each index in the database, eg.

    select *
    from pg_indexes
    where tablename not like 'pg%';
    
    0 讨论(0)
  • 2021-02-01 12:18

    You can use this query:

    select tablename,indexname,tablespace,indexdef from pg_indexes where tablename = 'your_table_name';

    where has tablename is a field in pg_indexes ,you an get an accurate indices by matching user defined table at 'your_table_name' at WHERE clause . This will give you the desired details.

    0 讨论(0)
  • 2021-02-01 12:22

    if you're in psql, then:

    \d tablename
    

    show Indexes, Foreign Keys and references...

    0 讨论(0)
提交回复
热议问题