是否有一个开源 SQL 数据库具有 Oracle 的“rowid”概念? 伪列?

发布于 2024-07-18 06:03:05 字数 111 浏览 5 评论 0原文

我知道 MySQL 和 PostgreSQL[1] 没有这个概念,所以我有兴趣找到一个确实有这个概念的开源 SQL 数据库。

[1] 后来有人指出PostgreSQL确实有rowid伪列。

I am aware that MySQL and PostgreSQL[1] do not have that concept, so I am interested in finding out of there is an open-source SQL database that does have the concept.

[1] It was later pointed out that PostgreSQL does have the rowid pseudo-column.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁吢 2024-07-25 06:03:06

PostgreSQL确实有这个概念。

有关 PostgreSQL 中伪列的简要列表,请参阅此处 ,其中 ctid 您感兴趣:

ctid(元组标识符)

描述元组在数据库中的物理位置的标识符。 ctid 表示一对数字:区块号和该区块内的元组索引。

这与 Oraclerowid 直接类似。

对于MySQL,前端无法获得行的物理位置。

MyISAM中,rowid只是从开头开始的文件偏移量,这就是存储在索引叶中的内容。

InnoDB 中,表按设计是索引组织的,这意味着它们始终具有某种主键,以及 InnoDB 表上的索引使用该PRIMARY KEY作为行指针。

对于 Oracle索引组织 表也是如此,其中 rowid 不是指向数据文件中块的物理指针,而是而是称为逻辑 ROWID 或 UROWID

如果您从 INDEX ORGANIZED 表中选择一个 ROWID >Oracle,您将看到它具有不同的格式(类似于 *BAEBwPICwQL+)。 这实际上是一个编码的PRIMARY KEY值。

请注意,如果您没有将任何列定义为 PRIMARY KEYMySQL 将创建一个隐藏的代理 PRIMARY KEY,您将永远不会有任何列控制。

这就是为什么您应该始终在 InnoDB 表中创建某种 PRIMARY KEY:它是免费的,并且您可以控制该列。

PostgreSQL does have this concept.

See here for a brief list of pseudocolumns in PostgreSQL, out of which ctid is of interest to you:

ctid (tuple identifier)

The identifier which describes the physical location of the tuple within the database. A pair of numbers are represented by the ctid: the block number, and tuple index within that block.

That is direct analog of Oracle's rowid.

As for MySQL, physical location of a row is not available for the front end.

In MyISAM, rowid is just a file offset from the beginning, and that's what is stored in the index leaves.

In InnoDB, tables are index organized by design, that means they always have some kind of a primary key, and the indexes over an InnoDB table use that PRIMARY KEY as a row pointer.

This is also true for Oracle's index organized tables, for which a rowid is not a physical pointer to a block in a datafile, but rather a such called logical ROWID, or UROWID

If you select a ROWID from an INDEX ORGANIZED table in Oracle, you will see that it has a different format (something like *BAEBwPICwQL+). This is in fact an encoded PRIMARY KEY value.

Note that if you have not defined any column as a PRIMARY KEY, MySQL will create a hidden surrogate PRIMARY KEY over which you will never have any control.

That's why you should always create some kind of a PRIMARY KEY in an InnoDB table: it's free, and you get control over the column.

故乡的云 2024-07-25 06:03:06

如果他们都没有这样做,那么其他人也不会这样做。

if neither of them have done that, then no others do.

债姬 2024-07-25 06:03:06

SQLite 有一个自动递增的“ROWID”列,您可以使用 ROWID、_ROWID 或 OID 访问该列。 如果您定义整数主键,那么它们将被别名。

SQLite has an auto incremented "ROWID" column which you can access using ROWID, _ROWID, or OID. If you define an integer primary key than they will be aliased.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文