gpt4 book ai didi

android - 在 SQLite 表中使用文本作为主键不好?

转载 作者:IT老高 更新时间:2023-10-28 23:11:08 25 4
gpt4 key购买 nike

在 SQLite 数据库中将文本作为主键是不是很糟糕?我听说由于性能原因这很糟糕,这是真的吗?在这种情况下,rowid 会被用作实际的主键吗?

最佳答案

Is it bad to have text as a primary key in an SQLite database? I heard that it's bad for performance reasons, is this true?

从正确性来看,TEXT PRIMARY KEY是可以的。

从性能的角度来看,更喜欢 INTEGER 键。但与任何性能问题一样,请自行衡量,看看您的数据和用例是否存在显着差异。

And will the rowid be used as the actual primary key in such a case?

只有 INTEGER PRIMARY KEY 使用 ROWID 别名。其他类型的主键没有,除非指定了 WITHOUT ROWID,否则会有隐式整数 rowid。 Reference .

关于android - 在 SQLite 表中使用文本作为主键不好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23157411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com