"P Kishor" <[EMAIL PROTECTED]> wrote: > On 7/2/07, Andre du Plessis <[EMAIL PROTECTED]> wrote: > > > > I would like to know how to create an Autoincrement field and insure > > that it is unique across the database, > > 1. Use a GUID, or > 2. Use some kind of crypt/md5 kinda function on a random string (same > effect as above), or > 3. Use a timestamp as a unique ID, esp. in conjunction with a hi-res > time lib, or > > Don't know if #1 and #2 above are built-in, but #3 could probably be > done without any external library. >
You can do #1 and/or #2 using the built-in randomblob() function. randomblob(N) returns a blob containing N bytes of good quality randomness (depending on how well the built-in PRNG was seeded). If you want your ID to be human readable, you might use the hex() function to convert the random blob into a hexadecimal string: INSERT INTO table1(id,...) VALUES(hex(randomblob(16)), ...); -- D. Richard Hipp <[EMAIL PROTECTED]> ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------