A question on using randomblob(16) to generate UUIDs, as the SQLite docs 
suggest: what assurance do you have that the UUID really is universally unique? 
 It's a pseudo-random number, and you can replicate a stream of pseudo-random 
numbers by setting the seed appropriately.  Is randomblob() doing some kind of 
magic in its seeding of the random number stream?

Will


On 1/24/11 3:49 AM, "Alexey Pechnikov" <pechni...@mobigroup.ru> wrote:

See
http://sqlite.mobigroup.ru/dir?name=ext/uuid

2011/1/24 sqlite-us...@h-rd.org <sqlite-us...@h-rd.org>

> Hi,
>
> I have put together a simple uuid generation method in sqlite:
>
>  select '{' || hex( randomblob(4)) || '-' || hex( randomblob(2))
>             || '-' || '4' || substr( hex( randomblob(2)), 2) || '-'
>             || substr('AB89', 1 + (abs(random()) % 4) , 1)  ||
>             substr(hex(randomblob(2)), 2) || '-' || hex(randomblob(6)) ||
> '}';
>
> It's based on the description for v.4 uuid's in wikipedia
> https://secure.wikimedia.org/wikipedia/en/wiki/Uuid .
>
> But I am thinking there may be a better (or another) method to do this
> in sqlite, without the need to use something external?
>
> thanks
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



--
Will Duquette -- william.h.duque...@jpl.nasa.gov
Athena Development Lead -- Jet Propulsion Laboratory
"It's amazing what you can do with the right tools."

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to