是否有一个开源 SQL 数据库具有 Oracle 的“rowid”概念? 伪列?
我知道 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
PostgreSQL
确实有这个概念。有关 PostgreSQL 中伪列的简要列表,请参阅此处 ,其中
ctid
您感兴趣:这与
Oracle
的rowid
直接类似。对于
MySQL
,前端无法获得行的物理位置。在
MyISAM
中,rowid
只是从开头开始的文件偏移量,这就是存储在索引叶中的内容。在
InnoDB
中,表按设计是索引组织
的,这意味着它们始终具有某种主键,以及InnoDB
表上的索引使用该PRIMARY KEY
作为行指针。对于
Oracle
的索引组织
表也是如此,其中rowid
不是指向数据文件中块的物理指针,而是而是称为逻辑 ROWID 或 UROWID如果您从
INDEX ORGANIZED
表中选择一个ROWID
>Oracle,您将看到它具有不同的格式(类似于*BAEBwPICwQL+
)。 这实际上是一个编码的PRIMARY KEY
值。请注意,如果您没有将任何列定义为
PRIMARY KEY
,MySQL
将创建一个隐藏的代理PRIMARY KEY
,您将永远不会有任何列控制。这就是为什么您应该始终在
InnoDB
表中创建某种PRIMARY KEY
:它是免费的,并且您可以控制该列。PostgreSQL
does have this concept.See here for a brief list of pseudocolumns in
PostgreSQL
, out of whichctid
is of interest to you:That is direct analog of
Oracle
'srowid
.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 areindex organized
by design, that means they always have some kind of a primary key, and the indexes over anInnoDB
table use thatPRIMARY KEY
as a row pointer.This is also true for
Oracle
'sindex organized
tables, for which arowid
is not a physical pointer to a block in a datafile, but rather a such calledlogical ROWID
, orUROWID
If you select a
ROWID
from anINDEX ORGANIZED
table inOracle
, you will see that it has a different format (something like*BAEBwPICwQL+
). This is in fact an encodedPRIMARY KEY
value.Note that if you have not defined any column as a
PRIMARY KEY
,MySQL
will create a hidden surrogatePRIMARY KEY
over which you will never have any control.That's why you should always create some kind of a
PRIMARY KEY
in anInnoDB
table: it's free, and you get control over the column.如果他们都没有这样做,那么其他人也不会这样做。
if neither of them have done that, then no others do.
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.