October 24 2014

DBMS_RANDOM

SELECT DBMS_RANDOM.normal() FROM dual;

DBMS_RANDOM

DBMS_RANDOM.NORMAL
  RETURN NUMBER;   --

This function returns random numbers in a standard normal distribution.

随机获取数据
select * from (select * FROM scott.emp order by dbms_random.random)
where rownum < 4

DROP TABLE test1 PURGE

CREATE TABLE test1 AS
SELECT LEVEL le,ABS(DBMS_RANDOM.RANDOM) a,ABS(DBMS_RANDOM.RANDOM) b,dbms_random.string(‘x’, 20) c,ABS(DBMS_RANDOM.RANDOM) d,ABS(DBMS_RANDOM.RANDOM) e
FROM dual CONNECT BY LEVEL < 2000000

SELECT * FROM test1;

 

–The basic function gets a random number, greater than or equal to 0 and less than 1, with 38 digits to the right of the decimal (38-digit –precision). Alternatively, you can get a random Oracle number x, where x is greater than or equal to low and less than high.

DBMS_RANDOM.VALUE(
  low  IN  NUMBER,
  high IN  NUMBER)

SELECT DBMS_RANDOM.value(5,10) FROM dual;
 

DBMS_RANDOM

DBMS_RANDOM.STRING
   opt  IN  CHAR,
   len  IN  NUMBER)
  RETURN VARCHAR2;

dbms_random.string(‘x’, 20)
‘u’, ‘U’ – returning string in uppercase alpha characters


‘l’, ‘L’ – returning string in lowercase alpha characters


‘a’, ‘A’ – returning string in mixed case alpha characters


‘x’, ‘X’ – returning string in uppercase alpha-numeric characters


‘p’, ‘P’ – returning string in any printable characters.

 

 



Copyright 2019. All rights reserved.

Posted 2014年10月24日 by ucjmh in category "oracle

Leave a Reply

Your email address will not be published. Required fields are marked *