我试图通过使用这个查询,但如何获取索引列表,其列名称及其表名称在数据库中的所有索引的列表?
SELECT * FROM pg_class,pg_index WHERE pg_class.oID = pg_index.indexrelID AND pg_class.oID IN ( SELECT indexrelID FROM pg_index,pg_class WHERE pg_class.oID=pg_index.indrelID AND indisunique != 't' AND indisprimary != 't' AND relname !~ '^pg_');`这将输出所有包含详细信息的索引(从我的视图定义中提取):
SELECT i.relname as indname,i.relowner as indowner,IDx.indrelID::regclass,am.amname as indam,IDx.indkey,ARRAY( SELECT pg_get_indexdef(IDx.indexrelID,k + 1,true) FROM generate_subscripts(IDx.indkey,1) as k ORDER BY k ) as indkey_names,IDx.indexprs IS NOT NulL as indexprs,IDx.indpred IS NOT NulL as indpredFROM pg_index as IDxJOIN pg_class as iON i.oID = IDx.indexrelIDJOIN pg_am as amON i.relam = am.oID;
可以向结尾添加一个额外的连接,以修剪命名空间:
SELECT i.relname as indname,IDx.indpred IS NOT NulL as indpredFROM pg_index as IDxJOIN pg_class as iON i.oID = IDx.indexrelIDJOIN pg_am as amON i.relam = am.oIDJOIN pg_namespace as nsON ns.oID = i.relnamespaceAND ns.nspname = ANY(current_schemas(false));总结
以上是内存溢出为你收集整理的列出PostgreSQL数据库的所有索引名称,列名称及其表名全部内容,希望文章能够帮你解决列出PostgreSQL数据库的所有索引名称,列名称及其表名所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)