列在索引中的位置 [英] Position of the column in the index

查看:122
本文介绍了列在索引中的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在PostgreSQL数据库中获取列在索引中的位置? pg_index目录表中的indkey给出了该列在表中的位置,但是我希望该列在其中包含索引的位置。

How to get the position of a column in the index in PostgreSQL database? indkey in pg_index catalog table gives the position of that column in it's table, but i want the position of the column in it's containing index.

推荐答案

这是一种方式。

SELECT c.relname, a.attname, a.attnum 
FROM pg_attribute a
INNER JOIN pg_class c on c.oid = a.attrelid 
WHERE c.relkind = 'i'
  AND c.relname = 'beds_pkey'
  AND a.attnum > 0

其中 beds_pkey 是索引。

这篇关于列在索引中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆