I had some tables on my database that have duplicate values, in order to get rid of those I made a small program that finds duplicates remove them and write new rows. By mistake, I commented the line that writes rows to database, and the only commands that were passed are the DELETE ones.

The reason I wanted to filter is that the database was taking too much space, now after that I lost all data I still see no space freed.

After operation, I had all rows deleted from the table, but the space that data has occupied remains the same.

My question is if I still can restore data in this case, and why space isn't getting freed after DELETE operations were done?

  • 2
    Unless you have backup your deleted data is not recoverable.
    – P.Salmon
    Nov 16 at 11:56
  • There are tools that independently work directly with the table file and allow you to copy data from there, even soft-deleted ones. But they are all paid.. So save the copy of your file with deleted data.
    – Akina
    Nov 16 at 13:10
  • Deleting data from a table won't release the space that it currently uses. You'll need to OPTIMIZE it afterwards. networkinghowtos.com/howto/…
    – MelvinLusk
    Nov 16 at 20:39

1 Answer 1


I have followed @melvinlusk 's solution, So I added an optimizations steps in my programs and now the space is getting freed after optimization, and I gave up restoring my data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.