在 SQLite 中使用 UUID [英] Using UUIDs in SQLite

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

问题描述

是否可以使用 UUID 值作为 SQLite 中的主键?我发现有关该主题的信息非常有限,因此我不确定 SQLite 是否甚至支持 UUID 数据类型.我应该将 UUID 存储为字符串吗?

Is it possible to use UUID values as a primary key in SQLite? I'm finding extremely limited information on the topic, so I'm not sure if SQLite even supports a UUID data type. Should I be storing a UUID as a string?

推荐答案

SQLite 允许使用任何数据类型 作为主键.

SQLite allows to use any data type as primary key.

UUID 可以存储为字符串(人类可读的)或 16 字节的 BLOB(如果记录太小以至于差异很重要,这可能会更快).

UUIDs can be stored either as strings (which are human-readable) or as 16-byte BLOBs (which might be faster if the records are so small that the difference matters).

这篇关于在 SQLite 中使用 UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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