Anonymity with Random Values in MySQL

Organisations can use data anonymization as a strategy to abide by strict data privacy rules that require the protection of personally identifiable information (PII), such as date of births, emails, identification details, monetary information, contact information, and information from health reports.

The following will assist in making the data anonymous.

1) Updating random values for text fields.

UPDATE `CustInfo`
SET  CustFirstName = SUBSTR( MD5( RAND()), 1, 10 ),
        CustLastName = SUBSTR( MD5( RAND()), 1, 10 );

2) Updating random values for monetary fields.

UPDATE `SalaryTable`
SET  Salary = FLOOR( RAND()* 10 ),
        Commission = FLOOR( RAND()* 10 ),
        TravelAllowances = FLOOR( RAND()* 10 );

3) Updating random values for emails.

UPDATE `CustTable`
SET  CustEmail = CONCAT(SUBSTRING(MD5(UUID()),1,15) , ‘@abc.com’);

Happy learning!!

Leave a Reply