In generating a large set of test data for report development, I had needed to populate a columns data with random numbers between a given range. Fortunately, Oracle provides this in the form of its DBMS_RANDOM package.
For my case, I needed to set a foreign keys value to anything within a range of values in another table. I know that my range in this other table is 1-100, so to update my table with those values, I would run something like:
Update mytable set myfield = trunc(DBMS_RANDOM.VALUE(1, 100))
The trunc became necessary since Oracle was spitting out values with decimals.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment