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

  • Home
  • SEARCH
  • 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 4334404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:31:28+00:00 2026-05-21T10:31:28+00:00

I am trying to clean up a database with a load of crap records

  • 0

I am trying to clean up a database with a load of crap records in it,

It is of a relational structure and there are foreign keys linking everything together, I have got a delete command set up:

DELETE FROM Members
WHERE (CurrentClass = 339) AND (YEAR(LastSessionDate) < 2011)

The DB structure looks like this:

Members
-----------------------------------------------------------------------
Id ¦ FirstName ¦ LastName ¦ JoiningClass ¦ CurrentClass ¦ CurrentScheme
-----------------------------------------------------------------------
0  ¦ Fakey     ¦ McFake   ¦ 123          ¦ 999          ¦ 2
-----------------------------------------------------------------------
1  ¦ Fakette   ¦ McFake   ¦ 123          ¦ 998          ¦ 1
-----------------------------------------------------------------------

The above table references tables Classes and Pricing on the fields JoiningClass, CurrentClass and CurrentScheme those tables then reference other tables with fields they hold, so basically everything references everything.

I want to delete the above records that match criteria of mine but I get a foreign key warning.

I had considered adding:

ON DELETE CASCADE

To it but I am afraid as everything references everything else it will delete ALL of the database data.

I.E. If I delete record 0 above that it will delete the classes 123 and 999 and that will in turn delete all of its references.

Does this happen or should I know better?

  • 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. Editorial Team
    Editorial Team
    2026-05-21T10:31:29+00:00Added an answer on May 21, 2026 at 10:31 am

    If “everything references everything” as you say, then it’s hard to tell what would happen exactly without some serious (read: time consuming, annoying) analysis of the schema. The same goes for using 3rd party tools – you’re never 100% sure what they’ll do exactly, and deleting records isn’t something you want to risk on a production database.

    Instead, you should create another copy of your database (backup your schema, then recreate it from backup on another server), add your cascading triggers and see what happens.

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

Sidebar

Related Questions

I have a database that I am trying to clean out. They have 70k
I'm trying to clean a recently imported sql server 2008 database that have to
I have an app on Heroku and need to clean up the database there,
I have output from grep I'm trying to clean up that looks like: <words>Http://www.path.com/words</words>
I'm trying to clean up a database table and I'd really like to drop
I am trying to clean up a legacy database by dropping all procedures that
I'm trying to write an UPDATE SQL Query to clean up my database a
I'm trying to come up with a clean database design for a new project
I am trying to load database data by using dbplannercalender1. procedure TForm1.DBPlannerCalendar1DaySelect(Sender: TObject; SelDate:
I have an extremely complicated relational database, which is causing me to use the

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.