Re: Droping indexes

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Droping indexes
Дата
Msg-id 1168964667.9586.8.camel@state.g2switchworks.com
обсуждение исходный текст
Ответ на Droping indexes  (Mario Behring <mariobehring@yahoo.com>)
Список pgsql-sql
On Tue, 2007-01-16 at 07:51, Mario Behring wrote:
> Hi all,
> 
> Please, if I drop all indexes from a table, can I recreate them after
> performing a vacuum full at this table? I mean, I do not know details
> about the indexes, so what I am asking is if I issue a REINDEX on this
> table, will it  create the proper indexes again?

The bad news:  No.  Once you drop an index it's just gone.
More bad news:  If it's a primary key index, you probably can't drop it
either.

Very good news:  PostgreSQL stores an index definition for easy index
recreation.  Let's say your tablename is "mytable"

This query will get you all the index creation statements for mytable:

select indexdef from pg_indexes where tablename='mytable';
CREATE UNIQUE INDEX mytable_pkey ON mytable USING btree (id)CREATE UNIQUE INDEX mytable_i1_key ON mytable USING btree
(i1)CREATEINDEX mytable_i1_i2 ON mytable USING btree (i1, i2)
 

Note that if you're using a schema other than the public one, you might
need to add 

tablespace='tablespacename' to the where clause.


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Removing CONTEXT message
Следующее
От: Frank Bax
Дата:
Сообщение: Re: Droping indexes