The method of randomly fetching data by oracle
This article introduces the knowledge of "the method of randomly fetching data from oracle". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
No matter on the Internet or in reality, I have a taste of loneliness, which is a kind of ORACLE random query 1.select * from (select * from tablename order by dbms_random.value) where rownum < N; Note: dbms_random is a package that can generate random values or strings. Value () is the most commonly used, and there are generally two uses of value (). The first function value return number; has no parameters and returns a value with a precision of 38 bits, ranging from 0.0 to 1.0, but not including 1.0. The following example: dbms_output.put_line (round (dbms_random.value*100)); the second value takes two parameters, the first refers to the lower limit and the second refers to the upper limit, which will generate a number from the lower limit to the upper limit, but does not include the upper limit, as follows: dbms_output.put_line (trunc (dbms_random.value (1101)); 2.select * from tablename sample (3) where rownum < 4
Select empno,empname from (select empno,empname from emp order by dbms_random.value ()) where rownum