mercredi 13 juillet 2016

How to add a randomly generated number to each row in one column in oracle?

Quick context: I need to mask data in a database. If anyone has any suggestions on how to do this better, those would be welcome as well as the answer to the question.

I am trying to add a randomly generated value to a number column in a database in order to keep the numbers realistic, but obscure the actual values. Here is what I have been trying to do so far:

select
   name, 
   price + round(DBMS_RANDOM.value(-10000,10000), 4)
from 
   items;

This is not working because the column returns only the randomly generated value without factoring in the price. For now I just want to be able to view the data, is there a better way to do this? Do I need to put the rounded value into a variable and loop to accomplish this?

Thanks!




Aucun commentaire:

Enregistrer un commentaire