List all index names, column names and its table name of a PostgreSQL database

后端 未结 6 1659
走了就别回头了
走了就别回头了 2020-12-12 13:40

What is the query to get the list all index names, its column name and its table name of a postgresql database?

I have tried to get the list of all indexes in a db b

6条回答
  •  天命终不由人
    2020-12-12 14:19

    The Query to list all the indexes of a database

    SELECT
      tablename,
      indexes [1],
      indexes [2],
      indexes [3],
      indexes [4],
      indexes [5],
      indexes [6],
      indexes [7],
      indexes [8],
      indexes [9],
      indexes [10]
    FROM (SELECT
      tablename,
      array_agg(indexname) AS indexes
    FROM pg_indexes
    WHERE schemaname = 'public'
    GROUP BY tablename) as sub;
    

提交回复
热议问题