How should I store GUID in MySQL tables?

CDR picture CDR · Jan 5, 2009 · Viewed 153.6k times · Source

Do I use varchar(36) or are there any better ways to do it?

Answer

thaBadDawg picture thaBadDawg · Jan 5, 2009

My DBA asked me when I asked about the best way to store GUIDs for my objects why I needed to store 16 bytes when I could do the same thing in 4 bytes with an Integer. Since he put that challenge out there to me I thought now was a good time to mention it. That being said...

You can store a guid as a CHAR(16) binary if you want to make the most optimal use of storage space.