List:General Discussion« Previous MessageNext Message »
From:Daevid Vincent Date:August 6 2007 9:06pm
Subject:RE: How can I delete a block of random rows?
View as plain text  
> -----Original Message-----
> From: Baron Schwartz [mailto:baron@stripped] 
> Sent: Saturday, 4 August 2007 12:41 PM
> Subject: Re: How can I delete a block of random rows?
> 
> Daevid Vincent wrote:
> > I have a SQL dump that I load in for testing with lots of 
> "interesting"
> > data.
> >  
> > I want to now pair that down to a smaller subset, however I 
> can't just
> > delete from a range of ID's, as the data is sequential.
> >  
> > I want to delete say 1000 random rows from the table.
> 
> What fraction of the rows do you want to delete? 10%?
> 
> DELETE FROM TABLE WHERE RAND() < .10;

Thanks! That works awesome. 

> -----Original Message-----
> From: Andrew Armstrong [mailto:andrew@stripped] 
> Sent: Friday, August 03, 2007 9:18 PM
> Subject: RE: How can I delete a block of random rows?
> 
> Are you sure you want to delete random rows, or do you (if you have
> sequential IDs) just want to delete every n'th row?
> 
> DELETE FROM table WHERE id MOD 5 = 0
> 
> Delete every 5th row from the table assuming sequential IDs 
> with no missing numbers.

I like this idea too, however after a certain point, it stops deleting.
:) 

Thread
How can I delete a block of random rows?Daevid Vincent4 Aug
  • Re: How can I delete a block of random rows?Baron Schwartz4 Aug
    • RE: How can I delete a block of random rows?Andrew Armstrong4 Aug
      • RE: How can I delete a block of random rows?Daevid Vincent6 Aug