I'd like to obfuscate data in specific columns in postgres 9.1.
For instance, I want to give all the people a 'random' first and last name.
I can generate a pool of names to use:
select name_first into first_names from people order by random() limit 500;
select name_last into last_names from people order by random() limit 500;
Both of those queries run in about 400ms (which works fine for me, assuming they only need to run once!)
Using a regular update statement doesn't work - this just does each select once, thus gives all the people the same name:
update people
SET name_last=(SELECT * from last_names order by random() limit 1),
name_first=(SELECT * from first_names order by random() limit 1)
where business_id=1;
How can I give each person a randomized name in postgres? I really don't want to do this in Ruby on Rails - I assume a pure SQL approach will be faster. However, speed isn't too much of a concern as I literally have all night for this business case.