How do I delete all entries I created today?
4 answers
Condition
WHERE created_at >= '2012-03-25'
AND created_at < '2012-03-26'
can be used to identify strings (and efficiently enough if there is an index on created_at
).
Make sure you back up the table (or better yet, the entire database) before dropping. Also, you can use some (temporary or temporary) table to store rows before deleting them from your table. Then you drop that temporary table when you're sure you've deleted the offending data - and nothing else:
CREATE TABLE wrong_data AS
SELECT *
FROM tableX
WHERE created_at >= '2012-03-25'
AND created_at < '2012-03-26' ;
DELETE t
FROM tableX AS t
JOIN wrong_data AS w
ON w.PK = t.PK ;
0
source to share