Re: Query that produces index information for a Table

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Query that produces index information for a Table
Дата
Msg-id 18449.1273367021@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Query that produces index information for a Table  ("Boyd, Craig" <craig@mysoftforge.com>)
Ответы Re: Query that produces index information for a Table  ("Boyd, Craig" <craig@mysoftforge.com>)
Список pgsql-general
"Boyd, Craig" <craig@mysoftforge.com> writes:
> I am trying to pull together some general information about indices
> (indexes?) for a particular table.
> I need the following: Index Name, Table Name, Column Name,
> Unique/Non-Unique, and ordinal position in the index.
> The information_schema.key_column_usage gets me most of the way there, I
> think, but does not tell me whether the index is unique and does not
> seem to differentiate between indices and other types of constraints.

The information_schema gets you *none* of the way there, actually,
because it's a creature of the SQL standard and indexes are outside the
standard (yes, really).  You can find out about unique constraints from
the information_schema views, but not about non-unique indexes, nor
even indexes that are unique but weren't created via unique-constraint
syntax.

If you want to know about all indexes, you'll need to get your hands
dirty with looking at the PG system catalogs.  I'd suggest looking at
the queries psql generates for \dt (use psql -E to watch these) and
then modifying them to suit your purposes.

            regards, tom lane

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

Предыдущее
От: "Boyd, Craig"
Дата:
Сообщение: Query that produces index information for a Table
Следующее
От: Tom Lane
Дата:
Сообщение: Re: psql weird behaviour with charset encodings