Title: foreign_keys preventing table drops
Last modified: February 13, 2017

---

# foreign_keys preventing table drops

 *  Resolved [SystemFailer](https://wordpress.org/support/users/systemfailer/)
 * (@systemfailer)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/foreign_keys-preventing-table-drops/)
 * Some plugins setup new database tables with foreign keys to tables like wp_post
   or wp_users.
 * With the presence of these foreign keys, it is preventing the wp_post and wp_users
   tables from getting dropped and the import cut short.
 * SOLUTION:
    add “SET foreign_key_checks = 0;” on the beginning of the SQL file
   and then “SET foreign_key_checks = 1;” on the end of the file

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Borislav Angelov](https://wordpress.org/support/users/bangelov/)
 * (@bangelov)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/foreign_keys-preventing-table-drops/#post-8798708)
 * Hi
 * Thanks for sharing that information!
 * Quick question, which version of the plugin are you using? Basically we have 
   internal logic to handle the problem with foreign keys and I am wondering what
   could be the problem.
 * Best Regards,
    Bobby
 *  Thread Starter [SystemFailer](https://wordpress.org/support/users/systemfailer/)
 * (@systemfailer)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/foreign_keys-preventing-table-drops/#post-8815417)
 * I was using the latest version of the plugin.
 *  Thread Starter [SystemFailer](https://wordpress.org/support/users/systemfailer/)
 * (@systemfailer)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/foreign_keys-preventing-table-drops/#post-8815430)
 * Oh and the table that had a foreign key to wp_post didn’t have the ‘wp_’ prefix
   so that could be a suspect on why the plugin didn’t detect the foreign key?
 *  Plugin Author [Borislav Angelov](https://wordpress.org/support/users/bangelov/)
 * (@bangelov)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/foreign_keys-preventing-table-drops/#post-8817978)
 * Hi
 * Yes, we export only tables that have current WP table prefix which is configured
   in wp-config.php
 * Best Regards,
    Bobby
 *  Thread Starter [SystemFailer](https://wordpress.org/support/users/systemfailer/)
 * (@systemfailer)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/foreign_keys-preventing-table-drops/#post-8819570)
 * Yeah that must be why foreign keys to wp_post and wp_users aren’t detect from
   plugins that don’t prefix their tables, so it should be fairly safe to do a SET
   foreign_key_checks = 0; since it would simply duplicate the database anyway so
   there shouldn’t be any problem by ignoring foreign key checks when importing 
   a database.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘foreign_keys preventing table drops’ is closed to new replies.

 * ![](https://ps.w.org/all-in-one-wp-migration/assets/icon-256x256.png?rev=2458334)
 * [All-in-One WP Migration and Backup](https://wordpress.org/plugins/all-in-one-wp-migration/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/all-in-one-wp-migration/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/all-in-one-wp-migration/)
 * [Active Topics](https://wordpress.org/support/plugin/all-in-one-wp-migration/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/all-in-one-wp-migration/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/all-in-one-wp-migration/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [SystemFailer](https://wordpress.org/support/users/systemfailer/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/foreign_keys-preventing-table-drops/#post-8819570)
 * Status: resolved