BOOLEAN or TINYINT confusion

前端 未结 5 726
面向向阳花
面向向阳花 2020-12-07 14:47

I was designing a database for a site where I need to use a boolean datetype to store only 2 states, true or false. I am using MySQL.
While designing the database using

5条回答
  •  日久生厌
    2020-12-07 15:17

    As of MySql 5.1 version reference

    BIT(M) =  approximately (M+7)/8 bytes, 
    BIT(1) =  (1+7)/8 = 1 bytes (8 bits)
    

    =========================================================================

    TINYINT(1) take 8 bits.
    

    https://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html#data-types-storage-reqs-numeric

提交回复
热议问题