是否可以在不删除 Firebird 的情况下停用索引?

Is it possible to deactivate index in Firebird without dropping it?

来自 RDB$INDICES System Table 处的 ib-aid link,RDB$INDICES 有一列 RDB$INDEX_INACTIVE 列,指示 active/inactive 状态。是否可以修改此列以激活或停用索引。可以这样做而不是 dropping/adding 索引吗?

是的,您可以使用 ALTER INDEX <indexname> {ACTIVE | INACTIVE},请参阅 ALTER INDEX in the Firebird 4.0 Language Reference 的文档。此声明适用于所有 Firebird 版本。

对于INACTIVE

With the INACTIVE option, the index is switched from the active to inactive state. The effect is similar to the DROP INDEX statement except that the index definition remains in the database. Altering a constraint index to the inactive state is not permitted.

最后一件事很重要:您不能对支持约束的索引执行此操作。

对于ACTIVE

With the ACTIVE option, if the index is in the inactive state, it will be switched to active state and the system rebuilds the index.

将已激活的索引更改为 ACTIVE 也将重建索引。