# Static (Fixed-Length) Table Characteristics

Static format is the default forMyISAMtables. It is used when the table contains no variable-length columns (VARCHAR,VARBINARY,BLOB, orTEXT). Each row is stored using a fixed number of bytes.

Of the threeMyISAMstorage formats, static format is the simplest and most secure (least subject to corruption). It is also the fastest of the on-disk formats due to the ease with which rows in the data file can be found on disk: To look up a row based on a row number in the index, multiply the row number by the row length to calculate the row position. Also, when scanning a table, it is very easy to read a constant number of rows with each disk read operation.

The security is evidenced if your computer crashes while the MySQL server is writing to a fixed-formatMyISAMfile. In this case,myisamchkcan easily determine where each row starts and ends, so it can usually reclaim all rows except the partially written one.MyISAM表索引总是可以根据数据行重建。




  • 字符VARCHAR列被空格填充到指定的列宽,尽管列类型没有改变。二进制变量列填充0x00字节到列宽。

  • 空值列在行中需要额外的空间来记录它们的值是否空值.每个空值column 需要额外的一位,四舍五入到最接近的字节。

  • 很快。

  • 易于缓存。

  • 崩溃后易于重建,因为行位于固定位置。

  • 除非您删除大量行并希望将可用磁盘空间返还给操作系统,否则无需重新组织。为此,请使用优化表要么myisamchk -r.

  • 通常比动态格式表需要更多的磁盘空间。

  • 使用以下表达式计算静态大小行的预期行长度(以字节为单位):

    row length = 1
                 + (sum of column lengths)
                 + (number of NULL columns + delete_flag + 7)/8
                 + (number of variable-length columns)

    *删除标志对于具有静态行格式的表,为 1。静态表在行记录中使用一个位作为标志,指示该行是否已被删除。删除标志*动态表为 0,因为标志存储在动态行标题中。