Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to select random records?

Re: How to select random records?

From: DBNerd <dbnerd_at_erols.com>
Date: 1997/09/27
Message-ID: <342DCDD5.59E8@erols.com>#1/1

Jerry,

Thank you for replying my posting. How can you convert a rownum to a rowid. Maybe row number in your posting is not rownum. Can you give me an example? Say I have a small table has 10 rows. I need to randomly select 3 out of these ten rows. How do I do it?

Thanks.
Bob
Jerry Gitomer wrote:
>
> Use a prime number hashing algorithm to develop a random row number,
> convert it into a rowid, select where rowid = calculated rowid
>
> You will have to some experimentation to get a good handle on how
> rowids are built. take a small table and retrieve the rowids and
> enough other information to tell which rowid applies to which row.
>
> Once you have it scoped out you will can either embed the logic in
> something that calls Oracle and retrieves each desired row in turn
> or build a list of desired rowids and then edit the list so that
> each desired row is called from a shell command, e,g,
>
> "sqlplus scott/tiger select * from table where rowid = '001.134.124';"
>
> Note that this is not the correct length for a rowid, but I wanted to
> fit the silly thing into one line :-)
>
> Jerry
>
> DBNerd wrote:
> >
> > Hi,
> >
> > Is there a way to select certain number records from a table randomly?
> > I am doing a survay application that needs to select records from table
> > randomly. What I am doing now is to select all records then fetch them
> > back and skip records periodically.
> > Is there a better way to do it?
> >
> > Thanks.
> > Bob
Received on Sat Sep 27 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US