BOOLEAN or TINYINT confusion

前端 未结 5 723
面向向阳花
面向向阳花 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

    MySQL does not have internal boolean data type. It uses the smallest integer data type - TINYINT.

    The BOOLEAN and BOOL are equivalents of TINYINT(1), because they are synonyms.

    Try to create this table -

    CREATE TABLE table1 (
      column1 BOOLEAN DEFAULT NULL
    );
    

    Then run SHOW CREATE TABLE, you will get this output -

    CREATE TABLE `table1` (
      `column1` tinyint(1) DEFAULT NULL
    )
    

提交回复
热议问题