Inserting hex value mysql

user524156 picture user524156 · Nov 29, 2010 · Viewed 28.6k times · Source

I have created an sql database using Java, I am a noob when it comes to sql but have it configured and set up, i have a table created which has two columns, the first being a big integer which increments, the second I have tried defining it as a char, varchar and binary but im still not getting the desired function, say i try and store 0a a hex number into the char column i get an error, i appended 0x to the beginning a it seems to store, but when i print out the contents it is blank or in some cases i get characters such as '/' or '?', I also tried using sql explorer and it gives me the same result viewing the table,

My problem is i need to store an eight character hex string such as eb8d4ee6.

Could someone please advise me of how this can be done?

Answer

Riedsio picture Riedsio · Dec 9, 2010

Here's a great blog post I always refer to to remind myself of the proper handling of hex values and binary fields, and lays out some performance implications.

http://www.xaprb.com/blog/2009/02/12/5-ways-to-make-hexadecimal-identifiers-perform-better-on-mysql/