list tables and their indexes

Поиск
Список
Период
Сортировка
От Johnson, Shaunn
Тема list tables and their indexes
Дата
Msg-id 73309C2FDD95D11192E60008C7B1D5BB05FED563@snt452.corp.bcbsm.com
обсуждение исходный текст
Список pgsql-general

Howdy:

Is there a way (SQL query) to get a list of
tables and their indexes (rather, what the
\di <index_name> brings back)?

I am doing the 'psql -U <name> -d <database> -E
to figure out how the description of \d <table>
give the 'Indexes:' information at the bottom of
the page, but I can't seem to figure out
how it's pulling that data back (aside from
querying against pg_class and pg_index and
why it is going there).

Just to make myself clear - I am not talking
about the following:

[snip]
SELECT c2.relname
FROM pg_class c, pg_class c2, pg_index i
WHERE c.relname = 't_table'
AND c.oid = i.indrelid AND i.indexrelid = c2.oid
AND NOT i.indisunique ORDER BY c2.relname
[/snip]

But something that I can put into a script to
to identify the table and bring back this:

[snip from \di <index_name>]
Index "t_table_2003_idx"
  Column   |  Type
-----------+---------
 person_id | integer
btree

[/snip from \di <index_name>}

Thanks in advance.

-X

В списке pgsql-general по дате отправления:

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: ERROR: Relation "pg_user" does not exist
Следующее
От: Albert Cervera Areny
Дата:
Сообщение: INSERT but no UPDATE or DELETE from windows