【问题标题】:why Boolean Data type are not working in MySQL?为什么布尔数据类型在 MySQL 中不起作用?
【发布时间】:2011-02-01 07:04:03
【问题描述】:

我正在使用 MySQL 5.5,并将其与我的 ASP.net 应用程序链接。

我添加了一个数据集以在 MySQL 存储过程中链接我的应用程序!!!

问题是当我调用任何包含 BOOLEAN 的存储过程时:

CREATE DEFINER=`root`@`localhost` PROCEDURE `SpCatDetailsDML`(
    ParDetDescription TEXT,
    ParDetDescriptionAR TEXT,
    ParPrice INT,
    ParCreatedOn DATETIME,
    ParDisplayOrder INT,
    ParAllowDisplay BOOLEAN,
    ParPictureID BIGINT,
    ParShowTypeID BIGINT
)
BEGIN-- INSERT --
    INSERT INTO cms.tbcatdetails(CatID,CustomerID,DetTitle,DetTitleAR,ShoertDesc,ShoertDescAr,DetDescription,
                                 DetDescriptionAR,Price,CreatedOn,DisplayOrder,AllowDisplay,PictureID,ShowTypeID) 
    VALUES (ParCatID,ParCustomerID,ParDetTitle,ParDetTitleAR,ParShoertDesc,ParShoertDescAr,ParDetDescription,
            ParDetDescriptionAR,ParPrice,ParCreatedOn,ParDisplayOrder,ParAllowDisplay,ParPictureID,ParShowTypeID);
END

当我将此存储过程添加到我的数据集时,它会向我显示一个警告,因为 ParAllowDisplay 数据类型是布尔值!!

有什么建议吗???

【问题讨论】:

    标签: asp.net mysql vb.net


    【解决方案1】:

    MySQL 中没有布尔数据类型。请改用TINYINT(1)

    请看这里http://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html


    奇怪,我在上面提到的 URL 中看到了BOOL, BOOLEAN。从来没有用过。

    另外,参考这篇文章 Which MySQL data type to use for storing boolean values

    【讨论】:

    • @ajreal 那么,我可以在创建表时使用BOOL 作为数据类型吗?我不记得我曾经使用过BOOL,我总是使用TINYINT(1)
    • 不,你不能我已经用过 BOOL 和同样的问题!!无论如何,我认为 TINYINT(1) 会解决这个问题。谢谢
    • @ajreal,@HAJJAJ——啊,太好了。谢谢。我一时糊涂了。
    猜你喜欢
    • 2011-01-24
    • 2018-09-24
    • 2011-08-19
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多