Friday, December 08, 2017

Generating a Random Number by Using DBMS_RANDOM Function

Generating a Random Number by Using DBMS_RANDOM Function


select dbms_random.value , --- Positive Number between (0,1)
      dbms_random.value (n,m), --- Positive decimal Number between (n,m), where n,m are Numbers
      trunc(dbms_random.value (n,m)), --- returns only Integer value between (n,m)
      dbms_random.string ('A',n),  -- alpha characters only (mixed case both upper and lower)
      dbms_random.string ('p',n),  -- any printable char (ASCII subset) including Special characters
      dbms_random.string ('U',n), --upper case alpha characters only and with range of n
      dbms_random.string ('L',n), --Lower case alpha characters only and with range of n
      dbms_random.string ('X',n),  -- any alpha-numeric characters (upper case only)
      sysdate + trunc(dbms_random.value (1,n)) ------- Random dates 
from dual
connect by level <=m  --- m rows


No comments:

Post a Comment

Clear BNE Cache for WebADI Changes

It Sometime happens that WebAdi Changes doesn't reflect once migrated in controlled instances. Here are the quick steps(Generally perfor...