The DBMS_RANDOM package

The DBMS_RANDOM package provides an API for the pseudo-random number generator.

-bash-3.2$ sqlplus scott/tiger

SQL*Plus: Release 11.2.0.3.0 Production on Thu May 9 17:47:21 2013

Copyright (c) 1982, 2011, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> SELECT ENAME FROM (SELECT ENAME FROM EMP ORDER BY dbms_random.value) WHERE ROWNUM = 1;

ENAME
----------
JONES

SQL> /

ENAME
----------
SMITH

SQL> /

ENAME
----------
ADAMS

SQL> /

ENAME
----------
ADAMS

SQL> /

ENAME
----------
ALLEN

http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_random.htm

http://www.oracle-base.com/articles/misc/dbms_random.php

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s