====== MySQL - Storing UUID ======
To store a UUID (128-bit unsigned integer). 128-bits = 16 bytes so use BINARY(16).
drop table if exists `some_table`;
create table `some_table` (
uuid binary(16) not null primary key
);
In order to store the UUID properly, the dashes should be removed and the UUID converted from hexadecimal representation to its binary form. This could be done in a single step with: UNHEX(REPLACE('id', '-', '')). Loading it from the a file could be done this way:
load data infile '/tmp/test.txt'
into table `some_table`
fields terminated by '\t'
lines terminated by '\n'
ignore 1 lines
(@var1)
set id = unhex(replace(@var1, '-', ''));
Of course when retrieving the 'uuid' field, you’ll need to HEX('id').