It can be done by using the package DBMS_RANDOM.
Different functions available in DBMS_RANDOM package :
- RANDOM
- VALUE
- STRING
Examples:
- select
SYS.DBMS_RANDOM.RANDOM FROM DUAL;
It will return any random value - SELECT SYS.DBMS_RANDOM.VALUE FROM DUAL;
It will return a numeric value between 0 and 1 - SELECT SYS.DBMS_RANDOM.VALUE(1,1000) FROM DUAL;
Returns any value between 1 and 1000.
We need to use TRUNC function to remove the decimal is generated by this package
SELECT TRUNC(SYS.DBMS_RANDOM.VALUE(1,1000)) FROM DUAL; - select SYS.DBMS_RANDOM.STRING('U',8) from DUAL;
Returns the string with the 8 characters in uppercase - select SYS.DBMS_RANDOM.STRING('L',8) from DUAL;
Returns the string with the 8 characters in lowercase
A --> Alpha numeric
X --> Alphanumeric with lower case
No comments:
Post a Comment