Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store varbinary in MySQL?

Just a quick question..

Out of two options mentioned below, how to store to varbinary column in MySQL?

public_key = '67498930589635764678356756719'

or

public_key = 67498930589635764678356756719

Will the second method work? I am into an emergency moment working on a production server and didn't want to experiment on it.

Thank you for any help.

like image 295
Nirmal Avatar asked Feb 02 '10 09:02

Nirmal


1 Answers

Printable data can be inserted using quotes. Non-printable data can be inserted using hexadecimal values. I.e.:

INSERT INTO Table(VarBinaryColumn) VALUES('Printable data') -- Will be stored as binary representation using the charset of the operating system

INSERT INTO Table(VarBinaryColumn) VALUES(0x12345) -- Non-printable binary data
like image 92
Håvard S Avatar answered Sep 25 '22 19:09

Håvard S