Check for existence of index

Поиск
Список
Период
Сортировка
Искать
От
David Rysdam
Тема
Check for existence of index
Дата
Msg-id
4252BF9F.3030009@ll.mit.edu
Список
Дерево обсуждения
Check for existence of index David Rysdam <drysdam@ll.mit.edu>
Re: Check for existence of index David Rysdam <drysdam@ll.mit.edu>
Re: Check for existence of index Tom Lane <tgl@sss.pgh.pa.us>
Re: Check for existence of index David Rysdam <drysdam@ll.mit.edu>
I have a script that automatically creates my database objects.  In 
order to automatically create indexes, it needs to first make sure they 
don't exist.

For things like tables, this is easy:

select * from information_schema.tables where table_schema = 
"" and table_name = ""

But for indexes it is hard for some reason.  There's a catalog table 
"pg_index", but it doesn't have index, schema or table names.  I 
eventually found them in pg_class but the table and schema names aren't 
there.

After some searching around, I came across this very strange (to me, 
anyway) "::regclass" thing that let me do this:

select * from pg_catalog.pg_index where indexrelid = 
'schema.index'::regclass

I'm not really clear what's that doing, but in any case it still isn't 
what I want.  That query returns information when the index exists but 
errors out when the index doesn't exist.  Is there a way I can get a 
non-erroring query on either condition that will tell me if an index 
exists on a given table in a given schema?
В списке pgsql-general по дате отправления
От: Hannes Dorbath
Дата:
От: Wes
Дата:
Сообщение: Re: Vacuum time degrading
FAQ