当用户隐藏所有列名时,如何使用 C API 可靠地获取/利用 SQLite 行 ID?

发布于 2024-12-28 10:16:39 字数 419 浏览 2 评论 0原文

根据SQLite文档,所有表默认都有rowid,并且不能删除。这个 rowid 可以通过 rowidoid_rowid_ 来访问。

不管怎样,数据库用户可以自由添加带有名称的新列,并且这些列将被隐藏。访问 rowid 的唯一方法是使用INTEGER PRIMARY KEY创建一个新列。

这是我目前的理解。有了这个,如果用户隐藏所有列并且用户没有创建任何 PK 列,我就没有可靠的方法来获取 rowid 。我也想过加个临时PK栏,但这也不太靠谱。如果这是真的,那就没有意义了。因为数据始终可用,但我只是无法访问,因为没有合适的接口。

所以我认为应该有一种方法来可靠地访问这些数据。但我找不到任何关于 C API 的东西。我可以为此提供一些指导吗?

According to SQLite documentation, All tables have rowid by default, and it cannot be removed. And this rowid can be accessed with rowid, oid or _rowid_.

Anyway database users can add the new column with the names freely, and the columns will be hidden. The only way to access rowid is making a new column with INTEGER PRIMARY KEY.

This is my current understanding. And with this, I have no reliable way to get the rowid if user hide all the columns and user didn't make any PK column. I have thought about adding temporary PK column, but this is unreliable too. If this is true, this doesn't make sense. Because the data is always available, and I just cannot access because there's no appropriate interface.

So I think there should be a way to access this data reliably. But I couldn't find anything with C API. Can I have some guidance for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文