selecting random records in an Oracle query

Posted on 2014-08-20
Last Modified: 2014-08-20

I would like to select a certain number of random records in an Oracle query.

FROM    (
        SELECT  *
        FROM    mytable
        ORDER BY
WHERE rownum <= 1000

I saw this code on the internet.  Can someone tell me what dbms_random.value is.  I
Question by:morinia
    1 Comment
    LVL 22

    Accepted Solution

    This is Oracle's built in random number generator

    See docs:

    So it orders by a randomly generated number.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
    Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
    This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now