Saturday, 27 October 2018

Generate Random number using SQL Query

Generate Random number

Here is the script to generate the random 10 digits number using SQL. And of course, this can be modified accordingly to suit the requirements.


Select SUBSTR('0000000000'||TO_CHAR(ROUND(DBMS_RANDOM.VALUE(1,10000000000),0)),-10) from dual;


This Select query generates a 10 digit random number. This will be useful for using generating primary keys when using on the primary key tables.




No comments:

Post a Comment