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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:35:06+00:00 2026-06-15T10:35:06+00:00

Foreign keys are causing me too many problems modifying an database structure to meet

  • 0

Foreign keys are causing me too many problems modifying an database structure to meet new requirements – I want to modify primary keys but it seems I can’t when foreign keys reference the table in question (I think because MySQL drops the table and re-creates).

So while I work on the DB, I’d like to simply remove all the foreign keys and re-create them later. Is there a neat way to do so?

  • 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-15T10:35:07+00:00Added an answer on June 15, 2026 at 10:35 am

    You can simply issue the following command before any Alter Table statements you are going to make:

    SET foreign_key_checks = 0;
    

    This will turn off foreign key constraint checks for your database connection. You can then make your changes without needing to worry about constraints.

    After you are done, don’t forget to issue:

    SET foreign_key_checks = 1;
    

    To turn them back on.

    Note that this will still not allow you to create a new foreign key constraint that would fail because the column data types don’t match.

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

Sidebar

Related Questions

Suppose I have many tables which have Foreign keys created. I want to get
No foreign keys defined in the database. So I've setup associations. problem: can't seem
I want to get relations (or foreign keys) of a Sql Server Table in
I added a bunch of foreign keys to the database project when previously there
I want to find all foreign keys in a table, and for each foreign
If I had two foreign keys in a table referencing the same primary key
I have a table with 2 foreign keys. I'm somewhat new to MySQL, can
Are foreign keys just for assuring the database consistency, or do they also affect
If two tables have foreign keys to the same primary key of another table,
Should items like Foreign Keys, Constraints, Default Values, etc be handled by the Database

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.