MySql 插入语句到二进制数据类型? [英] MySql insert statement to binary datatype?
本文介绍了MySql 插入语句到二进制数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是 MySQL 数据库.
I am using MySQL database.
我有一张表,其中包含数据类型为 binary(16) 的列.
I have one table having column with datatype binary(16).
我需要有关此表的插入语句的帮助.
I need help with the insert statement for this table.
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
如何解决这个问题?
推荐答案
您应该删除连字符以使值与字段的长度匹配...
You should remove the hyphens to make the value match the length of the field...
Example:
CREATE TABLE `assignedresource` (
`distid` binary(16) NOT NULL
)
insert into assignedresource values ('9fad5e9eefdfb449');
此外,MySQL 标准是使用这种表示法将字符串表示为二进制... X'9fad5e9eefdfb449',即
Also, MySQL standard is to use this notation to denote the string as binary... X'9fad5e9eefdfb449', i.e.
insert into assignedresource values (X'9fad5e9eefdfb449');
这篇关于MySql 插入语句到二进制数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文