bash for loop« an older post

Turn email addresses into fake addresses for testing databases

Snippet

When you have live data in a testing database, you don't want to trigger emails that go to your users. In the case where you need the rest of the data, and need valid email addresses, append .example.com to turn current valid email addresses into syntactically valid email addresses, but not emailable addresses.

UPDATE `orders` SET email = CONCAT(email, '.example.com') WHERE email NOT LIKE '%example.com';
 
-- alternately, to undo this change, use replace
 
UPDATE `orders` SET email = REPLACE(email, '.example.com', '');

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.