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

后端 未结 5 1225
无人共我
无人共我 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 22:56

    This is a mysql Jdbc configuration subject.

    You can config mysql jdbc to convert TinyInt(1) to Boolean or Integer through set jdbc url config property "tinyInt1isBit" to "true" (default) or "false".

    from: https://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html

    Should the driver treat the datatype TINYINT(1) as the BIT type (because the server silently converts BIT -> TINYINT(1) when creating tables)?

    Default: true

提交回复
热议问题