Skip to content

Instantly share code, notes, and snippets.

@samredai
Created December 10, 2018 00:07
Show Gist options
  • Save samredai/ac2c15db4243c59d745adb1ed7103724 to your computer and use it in GitHub Desktop.
Save samredai/ac2c15db4243c59d745adb1ed7103724 to your computer and use it in GitHub Desktop.
MySQL: Randomly delete a specified percentage of records from a table (90% in this example)
DELETE FROM tablename
WHERE idcolumn IN (
SELECT idcolumn
FROM (SELECT DISTINCT idcolumn FROM tablename) x
WHERE rand() <= 0.9
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment