Search code examples
databasesqliteguid

GUID as uniq key with SQLite


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?

Solution

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