在Oracle
数据库的表中的每一行数据都有一个惟一的标识符,称为rowid
,在Oracle
内部一般就是使用它来访问数据的。php
而在MySQL
中也有一个相似的隐藏列_rowid
来标记惟一的标识。可是须要注意_rowid
并非一个真实存在的列,其本质是一个非空惟一列的别名。html
PS:本文是基于MySQL 5.7
进行研究的mysql
在前文提到了_rowid
并非一个真实存在的列,其本质是一个非空惟一列的别名。为何会这么说呢?sql
由于在某些状况下_rowid
是不存在的,其只存在于如下状况:数据库
_rowid
其实就是指的是这个主键列_rowid
其实就是指的是对应非空惟一列。须要注意如下状况是不存在_rowid
的ui
详情能够参考MySQL
官方文档内容:code
If a table has a PRIMARY KEY or UNIQUE NOT NULL index that consists of a single column that has an integer type, you can use _rowid to refer to the indexed column in SELECT statements, as follows:htm
- _rowid refers to the PRIMARY KEY column if there is a PRIMARY KEY consisting of a single integer column. If there is a PRIMARY KEY but it does not consist of a single integer column, _rowid cannot be used.
- Otherwise, _rowid refers to the column in the first UNIQUE NOT NULL index if that index consists of a single integer column. If the first UNIQUE NOT NULL index does not consist of a single integer column, _rowid cannot be used.