> 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
http://sqlite.org/lang_corefunc.html
randomblob(N)
The randomblob(N) function return an N-byte blob containing pseudo-random
bytes. If N is less than 1 then a 1-byte random blob is returned.
Hint: applications can generate globally unique identifiers using this
function together with hex() and/or lower() like this:
hex(randomblob(16))
lower(hex(randomblob(16)))
Artur Reilin
sqlite.yuedream.de
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users