List all index names, column names and its table name of a PostgreSQL database -
what query list index names, column name , table name of postgresql database?
i have tried list of indexes in db using query how list of indexes, column names , table names?
select * pg_class, pg_index pg_class.oid = pg_index.indexrelid , pg_class.oid in ( select indexrelid pg_index, pg_class pg_class.oid=pg_index.indrelid , indisunique != 't' , indisprimary != 't' , relname !~ '^pg_');`
this output indexes details (extracted view definitions):
select i.relname indname, i.relowner indowner, idx.indrelid::regclass, am.amname indam, idx.indkey, array( select pg_get_indexdef(idx.indexrelid, k + 1, true) generate_subscripts(idx.indkey, 1) k order k ) indkey_names, idx.indexprs not null indexprs, idx.indpred not null indpred pg_index idx join pg_class on i.oid = idx.indexrelid join pg_am on i.relam = am.oid;
optionally add join end trim namespaces:
select i.relname indname, i.relowner indowner, idx.indrelid::regclass, am.amname indam, idx.indkey, array( select pg_get_indexdef(idx.indexrelid, k + 1, true) generate_subscripts(idx.indkey, 1) k order k ) indkey_names, idx.indexprs not null indexprs, idx.indpred not null indpred pg_index idx join pg_class on i.oid = idx.indexrelid join pg_am on i.relam = am.oid join pg_namespace ns on ns.oid = i.relnamespace , ns.nspname = any(current_schemas(false));
Comments
Post a Comment