表中的Oracle随机行 [英] Oracle random row from table

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

问题描述

我找到了从Oracle表中选择随机行的解决方案.实际上是以随机方式对行进行排序,但是您只能获取第一行以获得随机结果.

I found this solution for selecting a random row from a table in Oracle. Actually sorting rows in a random manner, but you can fetch only the first row for a random result.

SELECT *
FROM table
ORDER BY dbms_random.value;

我只是不明白它是如何工作的.在ORDER BY之后,它应该是用于排序的列.我看到"dbms_random.value"返回的值小于零.可以解释这种行为还是这样?

I just don't understand how it works. After ORDER BY it should be a column used for sorting. I see that "dbms_random.value" returns a value lower than zero. This behavior can be explained or is just like that?

谢谢

推荐答案

您也可以这样想:

SELECT col1, col2, dbms_random.value
FROM table
ORDER BY 3

在此示例中,数字3 =第三列

In this example the number 3 = the third column

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

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