Re: How to know the indexes on a Table

From: Frank Heikens <frankheikens(at)mac(dot)com>
To: Anirban Pal <anirban(dot)pal(at)newgen(dot)co(dot)in>
Cc: pgsql-novice(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: How to know the indexes on a Table
Date: 2009-06-13 08:05:35
Message-ID: 93029C19-801E-4B87-BF8B-547D6C4AE8F0@mac.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

> Hi all,
>
> Is there any way, to know the name of indexes on a table, defined in
> a database. I mean can I query something like
> Select Index_name from pg_class where relname = "Table_name" .
> Thanks in advance.
>
>
> --- Thanks & Reagrds ----
> Anirban Pal | Software Engineer
> Newgen Software Technologies Ltd.
> Contact: (011) 26815467-72 | Extn: 177
>
> Disclaimer :- This e-mail and any attachment may contain
> confidential, proprietary or legally privileged information. If you
> are not the origin al intended recipient and have erroneously
> received this message, you are prohibited from using, copying,
> altering or disclosing the content of this message. Please delete it
> immediately and notify the sender. Newgen Software Technologies Ltd
> (NSTL) accepts no responsibilities for los s or damage arising from
> the use of the information transmitted by this email including
> damages from virus and further acknowledges that no bin ding nature
> of the message shall be implied or assumed unless the sender does so
> expressly with due authority of NSTL.
>
>
>

Just take a look at the system catalogs, you'll find the view pg_index
as well http://www.postgresql.org/docs/8.3/static/catalog-pg-index.html

Example:
SELECT
nmsp.nspname AS schemaname,
tcls.relname AS tablename,
icls.relname AS indexname
FROM
pg_index
JOIN pg_class AS icls ON pg_index.indexrelid = icls.oid
JOIN pg_class AS tcls ON pg_index.indrelid = tcls.oid
JOIN pg_namespace AS nmsp ON tcls.relnamespace = nmsp.oid
WHERE
nmsp.nspname NOT IN ('pg_catalog', 'pg_toast')
ORDER BY
schemaname ASC,
tablename ASC,
indexname ASC;

Kind regards,
Frank

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2009-06-13 08:33:59 Re: [GENERAL] Using results from DELETE ... RETURNING
Previous Message Craig Ringer 2009-06-13 04:10:27 Re: How to store text files in the postgresql?

Browse pgsql-novice by date

  From Date Subject
Next Message David Saracini 2009-06-13 15:45:22 Views
Previous Message Andreas Kretschmer 2009-06-12 19:52:57 Re: UPGRADE