Subject Re: [firebird-support] Recreate indexes
Author Ivan Prenosil
> I'm trying to build a little store procedure to rebuild my indexex whenever
> I want...
>
> her3e you are:
>
> for select 'ALTER INDEX '||rdb$index_name ||' INACTIVE;'
> from rdb$indices
> where rdb$system_flag is null or rdb$system_flag = 0
> into :COMANDO
> do EXECUTE STATEMENT :COMANDO;
>
> /* ACTIVE Indici */
> for select 'ALTER INDEX '||rdb$index_name ||' ACTIVE;'
> from rdb$indices
> where rdb$system_flag is null or rdb$system_flag = 0
> into :COMANDO
> do EXECUTE STATEMENT :COMANDO;
>
> I suppose to identify no SYSTEM index using rdb$system_flag is null or
> rdb$system_flag = 0
> but if I run it I obtain an error who tell me:
>
> This operation is not defined for system tables.
> unsuccessful metadata update.
> MODIFY RDB$INDICES failed.
> action cancelled by trigger (3) to preserve data integrity.
> Cannot deactivate index used by a PRIMARY/UNIQUE constraint.
>
> soem idea?

Actually, you do not have to set indexes to inactive to rebuild them.
Setting them ACTIVE is enough (even if they already are active) !

Ivan