views:

41

answers:

2

I found GUID generation routine with python.

Running the code gives me the following results.

GUID: 00000129e0e72d9b2aab3c1500ac001000e90001
    Time:    Sat, 17 Jul 2010 09:55:33 (millis: 0.787)
    IP:      172.16.233.1
    Counter: 715865109

The comments of this code has the following message.

###   GUIDs make wonderful database keys.  They require no access to the 
###   database (to get the max index number), they are extremely unique, and they sort 
###   automatically by time.   GUIDs prevent key clashes when merging
###   two databases together, combining data, or generating keys in distributed
###   systems.

Questions

  • Does this work with SQLite? As far as I know INTEGER type in SQLite is 8 byte, and with 8 byte, it's not possible to store value 0x00000129e0e72d9b2aab3c1500ac001000e90001 or 101362835865894089778560972572099193929729 in decimal.
  • Is there any way to get unique ID globally with SQLite?
+2  A: 

Other than the fact that it takes up 32 bytes instead of 16, what's wrong with storing a GUID as text in SQLite?

mattmc3
@mattmc3 : Not much. BTW, Can SQLite store INTEGER with 16/32 bit?
prosseek
In SQLite3, they do support 64-bit integers. See here http://www.sqlite.org/version3.html and http://www.sqlite.org/c3ref/int64.html. I believe you define the column as a 'long' or 'unsigned long'.
mattmc3
A: 

Every SQLite data row has a 64 bit locally-unique identifier. SELECT rowid FROM table...