mysql设置boolean型会转为tinyint(1)在我本地的mysql上,我插入一个true,会自动转为1,插入到数据库,但是在我服务器上却不行。不知道是版本问题还是配置问题,请教一下大神
Is it true that when assigning a value, it is treated as a string with quotes?
If you write the SQL statement directly, it is better to write 0,1...
SQL
INSERT INTO ... VALUES(1);
As a programmer, you should be very sensitive to true/false, non-0 is true
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
ENUM('false', 'true') NOT NULL DEFAULT 'false'
Is it true that when assigning a value, it is treated as a string with quotes?
If you write the
SQL
statement directly, it is better to write 0,1...As a programmer, you should be very sensitive to true/false, non-0 is true
BOOLEAN is equivalent to TINYINT(1)
Use
ENUM('false', 'true') NOT NULL DEFAULT 'false'
to store true