Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 45779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:51:46+00:00 2026-05-10T15:51:46+00:00

Everyone has accidentally forgotten the WHERE clause on a DELETE query and blasted some

  • 0

Everyone has accidentally forgotten the WHERE clause on a DELETE query and blasted some un-backed up data once or twice. I was pondering that problem, and I was wondering if the solution I came up with is practical.

What if, in place of actual DELETE queries, the application and maintenance scripts did something like:

UPDATE foo SET to_be_deleted=1 WHERE blah = 50; 

And then a cron job was set to go through and actually delete everything with the flag? The downside would be that pretty much every other query would need to have WHERE to_be_deleted != 1 appended to it, but the upside would be that you’d never mistakenly lose data again. You could see ‘2,349,325 rows affected’ and say, ‘Hmm, looks like I forgot the WHERE clause,’ and reset the flags. You could even make the to_be_deleted field a DATE column, so the cron job would check to see if a row’s time had come yet.

Also, you could remove DELETE permission from the production database user, so even if someone managed to inject some SQL into your site, they wouldn’t be able to remove anything.

So, my question is: Is this a good idea, or are there pitfalls I’m not seeing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:51:47+00:00Added an answer on May 10, 2026 at 3:51 pm

    That is fine if you want to do that, but it seems like a lot of work. How many people are manually changing the database? It should be very few, especially if your users have an app to work with.

    When I work on the production db I put EVERYTHING I do in a transaction so if I mess up I can rollback. Just having a standard practice like that for me has helped me.

    I don’t see anything really wrong with that though other than ever single point of data manipulation in each applicaiton will have to be aware of this functionality and not just the data it wants.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At my work everyone has sql snippets that they use to answer questions. Some
Once again my silliness has struck. I would like to thank everyone who helped
I'm building some scripts for automatically setting up a developer's machine so everyone has
I guess everyone has already heard the news about some key developers leaving the
I'm trying to port the old HTML.Image helper, that I'm sure everyone has used
When I'm online it seems that everyone has agreed that using the exclusive locking
I am doing some sort of directory in ASP.NET, in which everyone has phone
Problem is, that I need to get non-standard font (not everyone has it on
I seem to be having the same problem that everyone has with Struts2 and
I am looking for a product search engine. Everyone has suggested Lucene.NET, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.