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)
 CREATE INDEX 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.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to