Subject Fixing corrupted indexes without restoring
Author Maya Opperman
Ann wrote:
>... And yes, deactivating and reactivating will fix all of those.

Horray, wonderful news!


> ... If
> you think your indexes are causing problems as they age, you could
just
> rebuild some of them each night rather than doing a full restore of
> the database.

> Deactivate and reactivate will do it.

OK I've been reading up on online FAQ's and Helen's brilliant book, but
I just want to double check that the following is safe to do, and won't
result in users being able to post duplicate keys, if something goes
wrong with reactivating an index for some odd reason:

(For Firebird 1.5)

SET TERM !! ;

EXECUTE BLOCK AS
DECLARE VARIABLE stmt VARCHAR(1000);
BEGIN
for select 'ALTER INDEX '||rdb$index_name ||' ACTIVE;'
from rdb$indices
into :stmt
do EXECUTE STATEMENT :stmt;

for select 'ALTER INDEX '||rdb$index_name ||' ACTIVE;'
from rdb$indices
into :stmt
do EXECUTE STATEMENT :stmt;
END!!

SET TERM ; !!