I'm trying to add a column to an existing database to store a UUID, and then retrieve the row with that record's UUID, but I keep getting an empty set. I created the column as BINARY(64) because when I tried BINARY(16) as some sites suggested, it wasn't long enough to hold the data. Here's my create statement:
ALTER TABLE `my_table` ADD `email_uuid` BINARY(64) NULL, ADD UNIQUE (`email_uuid`)
Then I populated it:
UPDATE `my_table` SET `email_uuid` = UUID();
To test it, I queried the table to get the UUID:
mysql> select emailaddr,email_uuid FROM my_table WHERE emailaddr = 'myemail@mydomain.com';
+------------------------------------------+------------------------------------------+
| emailaddr | email_uuid |
+------------------------------------------+------------------------------------------+
| myemail@mydomain.com | a332f4d4-ddb2-11e2-88f9-80ee731fd7a1 |
+------------------------------------------+------------------------------------------+
I've tried a few different ways to get that row back:
mysql> select emailaddr,email_uuid FROM my_table WHERE email_uuid = 'a332f4d4-ddb2-11e2-88f9-80ee731fd7a1';
Empty set (0.00 sec)
mysql> select emailaddr,email_uuid FROM my_table WHERE email_uuid = '{a332f4d4ddb211e288f980ee731fd7a1}';
Empty set (0.00 sec)
mysql> select emailaddr,email_uuid FROM my_table WHERE email_uuid = BIN('{a332f4d4ddb211e288f980ee731fd7a1}');
Empty set (0.02 sec)
mysql> select emailaddr,email_uuid FROM my_table WHERE email_uuid = '61333332663464342d646462322d313165322d383866392d38306565373331666437613100000000';
Empty set (0.00 sec)
mysql> select emailaddr,email_uuid FROM my_table WHERE email_uuid = UNHEX(REPLACE('a332f4d4-ddb2-11e2-88f9-80ee731fd7a1','-',''));
Empty set (0.02 sec)
Is there something I'm missing?