将十六进制值到MySQL [英] Insert hex values into MySql

查看:1184
本文介绍了将十六进制值到MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VARBINARY列的表。我需要插入一个字符串,如4D2AFF,这再presents十六进制值分别送出0x4d,0x2A到0xFF。我该如何构建这种说法?

I have a table with a VARBINARY column. I need to insert a string such as '4D2AFF' which represents the hex values 0x4D, 0x2A and 0xFF respectively. How do I construct this statement?

推荐答案

您可以使用<一个href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_unhex\"><$c$c>UNHEX()功能为一个十六进制转换以十六进制对二进制和<一个href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_hex\"><$c$c>HEX()做倒过来。

You can use UNHEX() function to convert a hexstring with hex pairs to binary and HEX() to do the other way round.

INSERT INTO tbl (col) VALUES (UNHEX('4D2AFF'))

SELECT HEX(col) FROM tbl

这篇关于将十六进制值到MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆