Random Sampling Of Data

Oracle9i New Feature Series: Random Data Sampling

The SELECT statement in Oracle9i provides the SAMPLE clause to read a random sample of data from table.

SELECT ...table_name SAMPLE [BLOCK] ( sample_percent )

You can sample the rows based on a random number of blocks instead of random rows. The BLOCK keyword must be included for block sampling. The optional sample percent must be less than 100.

When using the SAMPLE clause, the query must select only from one table, join queries are not supported.

SQL >select count(*) from test sample (1);
 
COUNT(*)
----------
341
 
1 row selected.
 
SQL >select count(*) from test;
 
COUNT(*)
----------
33574
 
1 row selected.
 
SQL > select count(*) * 100 from test sample (1);
 
COUNT(*)*100
------------
35000
 
1 row selected.
 
SQL >

Search BijooS.com Exact Match Search      
Home Oracle DBA TKMCE Alumni H1B Info Guestbook

Biju Thomas is Oracle7.3 OCP, Oracle8 OCP, 
Oracle8i OCP and Oracle9i OCA/OCP Certified DBA

Questions/Comments? Write to webmaster@bijoos.com. The scripts, tips and articles appearing on BijooS.com cannot be reproduced elsewhere without the prior permission from the webmaster.