在MySQL Workbench中的True/False数据类型

38 浏览
0 Comments

在MySQL Workbench中的True/False数据类型

请问有哪种数据类型可以在我的表中使用值“true”或“false”?

我可以选择BOOLEAN(或TINYINT)并使用值1和0,但只是想知道是否可以使用值“true”和“false”。

0
0 Comments

True

The error occurred because the column 'BoolCtrActv' was previously defined as a BOOLEAN datatype, but the value being inserted was 'False' which is a string. The BOOLEAN datatype in MySQL can only accept the values '1' for true and '0' for false.

To resolve this issue, the datatype of the column 'BoolCtrActv' needs to be changed from BOOLEAN to TINYINT. The TINYINT datatype can store integer values, which can be used to represent true and false as '1' and '0' respectively.

Here is an example of how to alter the table and change the datatype of the column:

ALTER TABLE careers.ntn
CHANGE COLUMN BoolCtrActv BoolCtrActv TINYINT NOT NULL;

After making this change, the column 'BoolCtrActv' will be able to accept values of '1' and '0', representing true and false, respectively.

0
0 Comments

MySQL Workbench中存在(True/False)数据类型的问题,原因是MySQL Workbench将TRUE和FALSE解析为字符串而不是布尔值。解决方法是在查询中使用数字1和0代替TRUE和FALSE。以下是详细的解决方法:

1. 打开MySQL Workbench并连接到数据库。

2. 在查询编辑器中输入查询语句。

3. 当需要使用布尔值时,将TRUE和FALSE替换为数字1和0。

4. 执行查询。

例如,如果原始查询是这样的:

SELECT * FROM table WHERE column = TRUE;

应该修改为:

SELECT * FROM table WHERE column = 1;

同样,如果原始查询是这样的:

SELECT * FROM table WHERE column = FALSE;

应该修改为:

SELECT * FROM table WHERE column = 0;

通过这种方式,我们可以在MySQL Workbench中正确使用布尔值,而不会遇到(True/False)数据类型的问题。

0