How can I know whether an index already exists

Started by kaifeng.zhualmost 16 years ago3 messagesgeneral
Jump to latest
#1kaifeng.zhu
cafeeee@gmail.com

Hi there,
How can I know whether an index already exists?
I have googled for hours and cannot found the solution...
Any response are appreciated.

#2Sergey Konoplev
gray.ru@gmail.com
In reply to: kaifeng.zhu (#1)
Re: How can I know whether an index already exists

On 23 June 2010 10:16, kaifeng.zhu <cafeeee@gmail.com> wrote:

Hi there,
How can I know whether an index already exists?

SELECT *
FROM pg_indexes
WHERE indexname ~ 'your_indexname';

--
Sergey Konoplev

Blog: http://gray-hemp.blogspot.com /
Linkedin: http://ru.linkedin.com/in/grayhemp /
JID/GTalk: gray.ru@gmail.com / Skype: gray-hemp / ICQ: 29353802

#3John R Pierce
pierce@hogranch.com
In reply to: kaifeng.zhu (#1)
Re: How can I know whether an index already exists

On 06/22/10 11:16 PM, kaifeng.zhu wrote:

Hi there,
How can I know whether an index already exists?
I have googled for hours and cannot found the solution...

query this table,

http://www.postgresql.org/docs/current/static/catalog-pg-class.html

possibly joined with...

http://www.postgresql.org/docs/current/static/catalog-pg-index.html

or query this view,
http://www.postgresql.org/docs/current/static/view-pg-indexes.html

those are all in the pg_catalog schema, which is shared by all databases