What is the replacement for uniqueidentifier in Mysql What is the replacement for uniqueidentifier in Mysql mysql mysql

What is the replacement for uniqueidentifier in Mysql


CREATE TABLE FOO (myid CHAR(38) NOT NULL,barid CHAR(38) NOT NULL);

According to MS website, GUID's are 38 chars in length.


The accepted answer, although not exactly wrong, is somewhat incomplete. There certainly are more space efficient ways to store GUID/UUIDs. Please have a look at this question: "Storing MySQL GUID/UUIDs"

This is the best way I could come up with to convert a MySQL GUID/UUID generated by UUID() to a binary(16):

UNHEX(REPLACE(UUID(),'-',''))

And then storing it in a BINARY(16)

If storage space of the GUID/UUID is a primary concern this method will deliver significant savings.


According the MySQL website you should match it to VARCHAR(64)

UNIQUEIDENTIFIER,   VARCHAR(64)

http://dev.mysql.com/doc/workbench/en/wb-migration-database-mssql-typemapping.html