gpt4 book ai didi

MySql 插入语句到二进制数据类型?

转载 作者:可可西里 更新时间:2023-11-01 06:36:01 25 4
gpt4 key购买 nike

我正在使用 MySQL 数据库。

我有一个表,其中包含数据类型为 binary(16) 的列。

我需要有关此表的插入语句的帮助。

Example:
CREATE TABLE `assignedresource` (
`distid` binary(16) NOT NULL
)

insert into assignedresource values ('9fad5e9e-efdf-b449');

Error : Lookup Error - MySQL Database Error: Data too long for column 'distid' at row 1

如何解决这个问题?

最佳答案

您应该删除连字符以使值与字段的长度匹配...

Example:
CREATE TABLE `assignedresource` (
`distid` binary(16) NOT NULL
)

insert into assignedresource values ('9fad5e9eefdfb449');

此外,MySQL 标准是使用此表示法将字符串表示为二进制...X'9fad5e9eefdfb449',即

insert into assignedresource values (X'9fad5e9eefdfb449');

关于MySql 插入语句到二进制数据类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9081216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com