Withdata Software

How to select N random records from an Oracle table

If you want to select N random records from an Oracle table, you need to change the clause as follows:

select * from
(
select*  from tableName  order by dbms_random.value
)
where rownum <= N;

For example, to select 5 random customers in the customers table, you use the following query:

select * from
(
select*  from customers order by dbms_random.value
)
where rownum <= 5;

Some Oracle tools you can try: https://www.withdata.com/oracle/