GUID与SQLite一起用作uniq键 [英] GUID as uniq key with SQLite

查看:141
本文介绍了GUID与SQLite一起用作uniq键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现使用python的GUID生成例程

运行代码可获得以下结果。

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该代码的注释具有以下消息。

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.



问题




  • 可与SQLite一起使用吗?据我所知,SQLite中的INTEGER类型为8字节,而8字节则无法以十进制存储值0x00000129e0e72d9b2aab3c1500ac001000e90001或101362835865894089778560972572099193929729。

  • 是否可以通过SQLite在全球范围内获取唯一ID?

  • 推荐答案

    除了占用32个字节而不是16个字节的事实外,将GUID作为文本存储在SQLite中又有什么问题呢?

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

    这篇关于GUID与SQLite一起用作uniq键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆