Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?
like image 891
prosseek Avatar asked Jul 17 '10 15:07

prosseek


2 Answers

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

like image 104
mattmc3 Avatar answered Oct 18 '22 15:10

mattmc3


Good article to help you get decision....

Primary Keys: IDs vs GUIDs:

http://www.codinghorror.com/blog/2007/03/primary-keys-ids-versus-guids.html

like image 44
WindRider Avatar answered Oct 18 '22 16:10

WindRider