Why does TINYINT(1) function as a boolean but INT(1) does not?

后端 未结 5 1228
无人共我
无人共我 2020-12-08 22:21

Why does TINYINT(1) work as a boolean? The way I understood the official docs, the (1) should mean it has a display width of 1, so if I store 56 in

5条回答
  •  既然无缘
    2020-12-08 23:12

    The engine is smart enough to know that TINYINT(1) and BOOL are the same. However INT(1) only affects the Display Width instead of the underlying storage size. Display width only comes into play when the value is less width then the display width. Then it gets padded.

    http://alexander.kirk.at/2007/08/24/what-does-size-in-intsize-of-mysql-mean/

提交回复
热议问题