读取 table 的当前 "metadata change counter"(版本计数)

Read current "metadata change counter" (version count) of a table

在 Firebird 中,每个 table 都有一个内部 1 字节 "metadata change counter",它将每个 table 的更改限制为 255。

有没有办法读取这个计数器的当前值?

Each change you make in table's structure is recorded in RDB$FORMATS system table. When you make 255 changes, you must do a backup and subsequent restore - which resets counter for all tables.

Source

要获取 table 的更改次数,您可以使用:

select max(t.rdb$format) from rdb$formats t
where
 t.rdb$relation_id = (select t2.rdb$relation_id from rdb$relations t2   
    where (t2.rdb$relation_name = 'MY_TABLE_NAME'))

获取 table 当前(最高)格式版本的最简单查询是

select rdb$format
from rdb$relations
where rdb$relation_name = 'TABLE_NAME'