除了固定的字段会占用空间,另外还有一些其它记录用的信息需要存储。The expected row length for dynamic-sized rows is calculated using the following expression: 3 + (number of columns + 7) / 8 + (number of char columns) + (packed size of numeric columns) + (length of strings) + (number of NULL columns + 7) / 8
insert into tbl(gender) values('男', '男', '女', '女');
mysql> SHOW TABLE STATUS LIKE 'tbl'\G
*************************** 1. row ***************************
Name: tbl
Engine: MyISAM
Version: 10
Row_format: Fixed
Rows: 4
Avg_row_length: 7
Data_length: 28
Max_data_length: 1970324836974591
Index_length: 1024
Data_free: 0
Auto_increment: NULL
Create_time: 2009-12-16 17:09:48
Update_time: 2009-12-16 17:13:29
Check_time: NULL
Collation: gb2312_chinese_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
Rows: 4
Avg_row_length: 7
Query OK, 0 rows affected (0.06 sec)mysql> insert into tbl(gender) values('男'),( '男'), ('女'),( '女');
Query OK, 4 rows affected (0.05 sec)
Records: 4 Duplicates: 0 Warnings: 0mysql> show table status like 'tbl'\G
*************************** 1. row ***************************
Name: tbl
Engine: MyISAM
Version: 10
Row_format: Fixed
Rows: 4
Avg_row_length: 7
Data_length: 28
Max_data_length: 1970324836974591
Index_length: 1024
Data_free: 0
Auto_increment: NULL
Create_time: 2009-12-16 19:40:28
Update_time: 2009-12-16 19:40:32
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)mysql> create table tbl1(gender SMALLINT) engine=myisam;
Query OK, 0 rows affected (0.06 sec)mysql> insert into tbl1 values(1),(2),(3),(4);
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0mysql> show table status like 'tbl1'\G
*************************** 1. row ***************************
Name: tbl1
Engine: MyISAM
Version: 10
Row_format: Fixed
Rows: 4
Avg_row_length: 7
Data_length: 28
Max_data_length: 1970324836974591
Index_length: 1024
Data_free: 0
Auto_increment: NULL
Create_time: 2009-12-16 19:42:31
Update_time: 2009-12-16 19:42:34
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)mysql>
+ (number of columns + 7) / 8
+ (number of char columns)
+ (packed size of numeric columns)
+ (length of strings)
+ (number of NULL columns + 7) / 8