database - GUID 作为 SQLite 的唯一键

标签 database sqlite guid

我找到了 GUID generation routine with python .

运行代码会得到以下结果。

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

这段代码的注释有如下信息。

###   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 个字节之外,在 SQLite 中将 GUID 存储为文本还有什么问题?

关于database - GUID 作为 SQLite 的唯一键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3272013/

相关文章:

SQLite错误无法识别的 token Unity

c# - 无法在 C#.NET 中将字符串转换为 GUID

sql - 如何在 SQL 语句中使用原始 Guid 而不是 little endian?

c# - Access数据库在c#中选择多行

iOS Sqlite3 SQLITE_ERROR

c# - 使用 sqlite-net 删除行的 SQLite 异常

guid - MS Dynamics CRM - 数据库 GUID

django - 获取 'DatabaseError' 对象在 DJango 中没有属性 'message'

.net - MySQLCommand BeginExecuteReader 缺少一个 AsyncCallback 参数,使其几乎无用

database - 将 magento 数据库从开发同步到生产