Oracle ROWID值 [英] Oracle ROWID values

查看:86
本文介绍了Oracle ROWID值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用以下查询从表中获取最后一条记录.

I was trying to get the last record from a table using the following query.

SELECT *
  FROM TABLE1
 WHERE ROWID IN (SELECT MAX (ROWID) FROM TABLE1);

当我选中ROWID时,

值是AAAZA5eAFAAA7AAAA

以及MIN(ROWID)的其他一些值.

在这里如何评估此pseudocolumn?还提到了 Oracle数据库不能保证此类列的值是有效的rowids .所以ROWID值在模式中不一定是唯一的吗?

How this pseudocolumn is getting evaluated here? It has also mentioned that Oracle Database does not guarantee that the values of such columns are valid rowids.So ROWID values are not necessarily unique within a schema?

根据文档: 数据库中的每一行都有一个地址.您可以通过查询伪列ROWID来检查行地址.该伪列的值是代表每行地址的字符串.这些字符串的数据类型为ROWID.您还可以创建包含具有ROWID数据类型的实际列的表和集群. Oracle Database不保证此类列的值是有效的rowid.

推荐答案

无法使用此方法获取表中的最后一行.行ID 可以更改,这意味着不一致,并且Oracle 从不保证它们以任何顺序重新创建.

You cannot get the last row in a table by this method. A rowid can change, which means it will not be consistent and Oracle never guarantees that they're created in any sort of order.

获取表最后一行的 only 可靠方法是使用数据在该表中.

The only reliable method of obtaining the last row of a table is to use the data in that table.

要真正回答您的问题,将以与您的NLS_SORT参数一致的方式评估伪列:

To actually answer your question the psuedocolumn is being evaluated in a manner consistent with your NLS_SORT parameter:

select value
  from nls_session_parameters
 where parameter = 'NLS_SORT';

VALUE
------------------------------
BINARY

在我的情况下,它是二进制的,这意味着数据库正在执行二进制排序,以便确定一个值是否比另一个值更大".可以将其视为 ASCII表A的十进制ASCII值为65,u的值为117.这意味着A排在u之上.

In my case it's binary, which means that the database is performing a binary sort in order to work out whether any one value is "greater" than another. Think of it as if it were the ASCII table; the decimal ASCII value for A is 65 and the value for u is 117. This means that A is sorted above u.

这篇关于Oracle ROWID值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆