enum('男', '女');

解决方案 »

  1.   

    做了个实验,好像是7个字节:create table(gender enum('男', '女'));
    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
      

  2.   

    mysql> create table tbl(gender enum('男', '女')) engine=myisam;
    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>
      

  3.   

    除了固定的字段会占用空间,另外还有一些其它记录用的信息需要存储。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
      

  4.   

    说的不完全正确,在一张表中enum类型应该是占用1个或2个字节,取决于此表中enum类型的个数,enum类型字段占用的总字节数应该等于enum类型数量+1个字节。