我想在我的.NET应用程序中连接到数据库服务器并执行生成一系列数据库统计信息的数据库命令。问题是它不以结构化格式返回统计信息,它以纯文本形式返回(如UNIX中的df -k
命令)我可以捕获输出并解析它,但我想知道是否有更好地接近这样的事情。
我当然想不出另一种选择,但我想问一下。解析命令结果似乎有点脆弱,因为如果数据库作者改变了格式,我就会破坏。
编辑:数据库是IBM UniData数据库。该命令是“file.stat”,它返回平均记录大小,最大记录大小等
答案 0 :(得分:2)
是的,解析说明。但是,您应该首先检查数据库版本。
:version
Module Name Version Licensed
UniData RDBMS............ 7.1 Yes
这样,如果file.stat数据发生变化,你可以调用备用例程 注意: file.stat输出数据有时是静态的,不太可能改变。
:file.stat TEST
File name = TEST
Number of groups in file (modulo) = 3
Static hashing, hash type = 0
Block size = 2048
Number of records = 12
Total number of bytes = 2335
Average number of records per group = 4.0
Standard deviation from average = 1.0
Average number of bytes per group = 778.3
Standard deviation from average = 286.2
Average number of bytes in a record = 194.6
Average number of bytes in record ID = 4.3
Standard deviation from average = 42.3
Minimum number of bytes in a record = 113
Maximum number of bytes in a record = 270
Minimum number of fields in a record = 66
Maximum number of fields in a record = 80
Average number of fields per record = 72.7
Standard deviation from average = 6.5
The actual file size in bytes = 8192.