List:General Discussion« Previous MessageNext Message »
From:Sergei Golubchik Date:May 13 2004 6:39am
Subject:Re: GUID storage
View as plain text  
Hi!

On May 12, Larry Lowry wrote:
> A uniqueidentifier in MS SQL is basically a guid.  I am generating
> them via System.Guid.NewGuid().ToString(N") in the Dot Net
> framework which now returns me a string of 32 characters (hex). 
> Internally I understand it is a 128-bit integer.  As an option I could
> store that in MySql.  What data type would that be?
> 
> How would one convert to binary char(16)?  In what documentation
> would I find this?   I do not know enough yet to write a UDF.  

In 4.1.2 you can use function UNHEX():

  UNHEX(REPLACE(uuid, '-', ''))

will convert uuid to 16-byte string
There's no easy way to do a reverse conversion yet. HEX() will do, but
you'll lose dashes.
 
Regards,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  MySQL AB, Senior Software Developer
/_/  /_/\_, /___/\___\_\___/  Osnabrueck, Germany
       <___/  www.mysql.com
Thread
GUID storageLarry Lowry12 May
  • Re: GUID storageMike Hillyer12 May
  • Re: GUID storageJeremy Zawodny12 May
    • Re: GUID storageUnknown Sender29 Jun
      • Re: GUID storageDan Nelson29 Jun
  • Re: GUID storageDan Nelson12 May
  • Re: GUID storageLarry Lowry12 May
    • Re: GUID storageDan Nelson13 May
    • Re: GUID storageSergei Golubchik13 May