Created
December 10, 2018 00:07
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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