0
有時我在表中有超過1百萬行。隨機化行更新
每批將有100,000個隨機行。
隨機化行的最佳方法是什麼?
我做到以下幾點:
UPDATE temp1 SET `batch` = '';
UPDATE temp1 SET `batch` = 'B1' WHERE batch = '' order by rand(number) limit 100000;
UPDATE temp1 SET `batch` = 'B2' WHERE batch = '' order by rand(number) limit 100000;
UPDATE temp1 SET `batch` = 'B3' WHERE batch = '' order by rand(number) limit 100000;
UPDATE temp1 SET `batch` = 'B4' WHERE batch = '' order by rand(number) limit 100000;
UPDATE temp1 SET `batch` = 'B5' WHERE batch = '' order by rand(number) limit 100000;
你到底想達到什麼目的?爲什麼要隨機更新? (因爲最後,所有匹配的行都會被更新) –
我隨機化'numbers'字段,因爲當前的數字按順序排序。一旦它被隨機化,我將每個批次導出爲CSV。 – user1246800