Remove a foreign key from the MySQL database

Source: Internet
Author: User
Magento database imports and exports to process foreign keys. After testing, the foreign key can be removed smoothly with this section added.

Magento database imports and exports to process foreign keys. After testing, the foreign key can be removed smoothly with this section added.

Magento database imports and exports to process foreign keys.

After testing, the foreign key can be removed smoothly with this section added.

Header
/*! 40101 SET @ OLD_CHARACTER_SET_CLIENT = @ CHARACTER_SET_CLIENT */;
/*! 40101 SET @ OLD_CHARACTER_SET_RESULTS = @ CHARACTER_SET_RESULTS */;
/*! 40101 SET @ OLD_COLLATION_CONNECTION = @ COLLATION_CONNECTION */;
/*! 40101 set names utf8 */;
/*! 40103 SET @ OLD_TIME_ZONE = @ TIME_ZONE */;
/*! 40103 SET TIME_ZONE = '+ '*/;
/*! 40014 SET @ OLD_UNIQUE_CHECKS =@ UNIQUE_CHECKS, UNIQUE_CHECKS = 0 */;
/*! 40014 SET @ OLD_FOREIGN_KEY_CHECKS = @ FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0 */;
/*! 40101 SET @ OLD_ SQL _MODE = @ SQL _MODE, SQL _MODE = 'no _ AUTO_VALUE_ON_ZERO '*/;
/*! 40111 SET @ OLD_ SQL _NOTES = SQL _notes, SQL _NOTES = 0 */;
/*! 40101 SET @ OLD_CHARACTER_SET_CLIENT = @ CHARACTER_SET_CLIENT */;
/*! 40101 SET @ OLD_CHARACTER_SET_RESULTS = @ CHARACTER_SET_RESULTS */;
/*! 40101 SET @ OLD_COLLATION_CONNECTION = @ COLLATION_CONNECTION */;

Tail
/*! 40101 SET SQL _MODE = @ OLD_ SQL _MODE */;
/*! 40014 SET FOREIGN_KEY_CHECKS = @ OLD_FOREIGN_KEY_CHECKS */;
/*! 40014 SET UNIQUE_CHECKS = @ OLD_UNIQUE_CHECKS */;
/*! 40101 SET CHARACTER_SET_CLIENT = @ OLD_CHARACTER_SET_CLIENT */;
/*! 40101 SET CHARACTER_SET_RESULTS = @ OLD_CHARACTER_SET_RESULTS */;
/*! 40101 SET COLLATION_CONNECTION = @ OLD_COLLATION_CONNECTION */;
/*! 40111 SET SQL _NOTES = @ OLD_ SQL _NOTES */;

Method 2

Disable related database keyword relationships forcibly:
SET @ OLD_CHARACTER_SET_CLIENT = @ CHARACTER_SET_CLIENT;
SET @ OLD_CHARACTER_SET_RESULTS = @ CHARACTER_SET_RESULTS;
SET @ OLD_COLLATION_CONNECTION = @ COLLATION_CONNECTION;
Set names utf8;
SET @ OLD_UNIQUE_CHECKS =@ UNIQUE_CHECKS, UNIQUE_CHECKS = 0;
SET @ OLD_FOREIGN_KEY_CHECKS = @ FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0;
SET @ OLD_ SQL _MODE = @ SQL _MODE, SQL _MODE = 'no _ AUTO_VALUE_ON_ZERO ';
SET @ OLD_ SQL _NOTES = SQL _notes, SQL _NOTES = 0;

Restore related database keyword relationships:


SET SQL _MODE = @ OLD_ SQL _MODE;
SET FOREIGN_KEY_CHECKS = @ OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS = @ OLD_UNIQUE_CHECKS;
SET CHARACTER_SET_CLIENT = @ OLD_CHARACTER_SET_CLIENT;
SET CHARACTER_SET_RESULTS = @ OLD_CHARACTER_SET_RESULTS;
SET COLLATION_CONNECTION = @ OLD_COLLATION_CONNECTION;
SET SQL _NOTES = @ OLD_ SQL _NOTES;

Both methods are OK to remove the foreign key from the mysql database.

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.