【发布时间】:2018-12-16 01:59:51
【问题描述】:
这里是来自https://stackoverflow.com/a/2213199/3284469的查询,它得到一个表的索引信息。
为什么我们有两个别名pg_class by pg_class t 和pg_class i?
i.oid = ix.indexrelid可以替换成t.oid = ix.indexrelid吗?
谢谢。
select
t.relname as table_name,
i.relname as index_name,
a.attname as column_name
from
pg_class t,
pg_class i,
pg_index ix,
pg_attribute a
where
t.oid = ix.indrelid
and i.oid = ix.indexrelid
and a.attrelid = t.oid
and a.attnum = ANY(ix.indkey)
and t.relkind = 'r'
and t.relname like 'test%'
order by
t.relname,
i.relname;
【问题讨论】:
标签: sql postgresql