SQLite - 是否可以使非整数主键工作?
感谢您的阅读并希望得到答复,
由于遗留问题和公司政策,我正在使用 SQLite 2.8.17 并有一些 varchars 作为主键。
但是,当我运行“pragmaintegrity_check”时,它会报告“索引中缺少rowid”和“索引中的条目数错误”具有 varchar 主键的表,但返回结果是 OK。
扩展常量数据库访问和使用(大约一天的负载测试)似乎会导致数据库故障(完整性检查返回 FAIL)和唯一的解释(通过 .explain)与之前的错误相同(“索引中缺少 rowid” 和 “索引中的条目数错误”)。
有人可以帮忙吗?我做错了什么吗?
谢谢。
Thanks for reading and hopefully answering,
Due to legacy issues and company policy, I am working with SQLite 2.8.17 and have a few varchars as primary keys.
But when I run a "pragma integrity_check", it reports "rowid missing from index" and "wrong # of entries in index" on the tables with the varchar primary key but the returned result is an OK.
Extended Constant DB access and usage (about a day of load testing) seems to result in a DB failure (integrity check returns FAIL) and the only explanation (via .explain) is the same errors as earlier ("rowid missing from index" and "wrong # of entries in index").
Can anyone help? Is there something wrong that I am doing?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您清理数据库,那么至少应该在没有完整性检查失败的情况下重新构建它。然后,按照您所说的尝试访问和使用一天,看看错误是否仍然存在。
要清理数据库,可以在命令行中输入数据库并键入:
VACUUM;
,或者使用命令行:(尽管我似乎记得SQLite2在
VACUUM
之后需要一个表名) code>,因此您可能需要进行一些实验,但它仍然会影响所有表。)If you vacuum the database, that should at the very least re-construct it without this integrity check failure. Then, try a day of access and usage, as you say, and see if the error is still present.
To vacuum a database, either enter the database in command line and type:
VACUUM;
, or use a command line:(although I seem to remember that SQLite2 needed a table name after
VACUUM
, so you might need to experiment a little. It will affect all tables nonetheless.)