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 8814679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:11:22+00:00 2026-06-14T04:11:22+00:00

Problem Statement: I want to drop some tables in a databases. Error getting: a

  • 0

Problem Statement: I want to drop some tables in a databases.

Error getting: a foreign key constraint fails

Details:

I have a pre-existing (not populated by django models.py) database. I am using django. I used this database for creating django site. I have given its name and proper setting while creating a site in django. There are no models in created in models.py.

After executing command:

python manage.py syncdb

Django added following tables to that database:

| auth_group |

| auth_group_permissions |

| auth_permission |

| auth_user |

| auth_user_groups |

| auth_user_user_permissions |

| django_content_type |

| django_session |

| django_site |

I want to drop all these tables.

I tried this query;

DROP TABLE table_name;

but mysql prompted with error showing:

ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

Is there some way I can drop only above mentioned tables keep my pre-existing tables intact?

Thank you.

  • 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-06-14T04:11:24+00:00Added an answer on June 14, 2026 at 4:11 am

    Two possibilities:

    1. There is a table within another schema (“database” in mysql terminology) which has a FK reference
    2. The innodb internal data dictionary is out of sync with the mysql one.

    You can see which table it was (one of them, anyway) by doing a “SHOW ENGINE INNODB STATUS” after the drop fails.

    If it turns out to be the latter case, I’d dump and restore the whole server if you can.

    MySQL 5.1 and above will give you the name of the table with the FK in the error message.

    and try this too

    Please refer this question stackoverflow

    Disable foreign key checking

    DISABLE KEYS
    

    Do make sure to SET FOREIGN_KEY_CHECKS=1;

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

Sidebar

Related Questions

I have an big problem with an SQL Statement in Oracle. I want to
Problem Statement:- I have four shell script that I want to execute only when
Problem statement We have one employer that wants to interview N people, and therefore
I'm having some problem with this statement declare @result int select @result = (select
I have a problem with a continue statement in my C# Foreach loop. I
Problem statement:- I want to create 50 instances of a vector(1 Dimension) which contains
My problem statement is : I want to write design file management (add, copy,
I have some drop down boxes that store counties and constituencies in them. When
I have a myism table 'test' which holds some out-dated data, now I want
Problem statement: For a given positive number, I have to find out the immediately

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.