Home  >  Q&A  >  body text

数据库 - mysql boolean型无法插入true

mysql设置boolean型会转为tinyint(1)
在我本地的mysql上,我插入一个true,会自动转为1,插入到数据库,但是在我服务器上却不行。
不知道是版本问题还是配置问题,请教一下大神

巴扎黑巴扎黑2743 days ago685

reply all(5)I'll reply

  • 高洛峰

    高洛峰2017-04-17 16:28:44

    Is it true that when assigning a value, it is treated as a string with quotes?

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 16:28:44

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 16:28:44

    If you write the SQL statement directly, it is better to write 0,1...

    INSERT INTO ... VALUES(1);

    reply
    0
  • 迷茫

    迷茫2017-04-17 16:28:44

    As a programmer, you should be very sensitive to true/false, non-0 is true

    reply
    0
  • 阿神

    阿神2017-04-17 16:28:44

    BOOLEAN is equivalent to TINYINT(1)

    These types are synonyms for TINYINT(1). A value of zero is considered false. Nonzero values ​​are considered true

    Use ENUM('false', 'true') NOT NULL DEFAULT 'false' to store true

    reply
    0
  • Cancelreply