如果您手头有 Firebird 安装,您可以使用 gstat 检查数据库的 ODS。例如:
gstat -h <path-to-your-database>
如果 gstat 版本支持数据库的 ODS 版本,您将获得类似以下内容:
Database "D:\DATA\DB\FB4\FB4TESTDATABASE.FDB"
Gstat execution time Sat Mar 17 18:08:09 2018
Database header page information:
Flags 0
Generation 308
System Change Number 0
Page size 16384
ODS version 13.0
Oldest transaction 393
Oldest active 394
Oldest snapshot 394
Next transaction 395
Sequence number 0
Next attachment ID 150
Implementation HW=AMD/Intel/x64 little-endian OS=Windows CC=MSVC
Shadow count 0
Page buffers 0
Next header page 0
Database dialect 3
Creation date Jan 6, 2017 14:05:48
Attributes force write
Variable header data:
*END*
这里ODS version 13.0
的意思是它是一个 Firebird 4 数据库。
如果 gstat 版本不支持数据库的 ODS 版本,您将收到类似错误(例如,在这种情况下,在 Firebird 2.5/ODS 11.2 数据库上使用 Firebird 4 gstat):
Wrong ODS version, expected 13, encountered 11
但是,这有其缺点:它不提供 ODS 次要版本,例如,当使用 Firebird 2.0 (ODS 11.0) 或 2.1 (ODS 11.1) gstat 访问 Firebird 2.5 (ODS 11.2) 数据库时,这将导致无用的错误消息:
Wrong ODS version, expected 11, encountered 11
最快的方法是使用 Firebird 2.5 gstat,因为这将允许您查明 10 (Firebird 1) 和 11.2 (Firebird 2.5) 之间的确切 ODS 版本,同时错误消息将允许您查明是否需要较新的版本(例如 ODS 12 是 Firebird 3,ODS 13 是 Firebird 4)。
但是,您还需要查看Implementation
gstat 的输出。Firebird 数据库文件具有特定于平台的存储(尽管自 Firebird 2.0 以来这已减少)。例如,在 Firebird 1.5 和更早版本 (ODS 10) 中,64 位 Firebird 无法访问来自 32 位 Firebird 的数据库。来自小端平台(最常见)的 Firebird 数据库无法在大端平台上读取(反之亦然)。
在这些限制内,Firebird 2.5 安装可以使用 ODS 10 到 11.2 读取数据库。Firebird 3 只能读取 ODS 12,而 Firebird 4 只能读取 ODS 13。
如果存在平台不匹配(例如旧的 32/64 位或小/大端)或不受支持的 ODS 版本,您将需要有一个可传输备份 (gbak) 来转换和/或升级。
有关 ODS 版本和随附的 Firebird(或 InterBase)版本的概述,请参阅所有 Firebird 和 InterBase On-Disk-Structure (ODS) 版本。