Skip to content

Instantly share code, notes, and snippets.

@phil-hildebrand
Created October 31, 2016 22:19
Show Gist options
  • Save phil-hildebrand/5fd16b40a5e906d4bd2db476e6bb58ba to your computer and use it in GitHub Desktop.
Save phil-hildebrand/5fd16b40a5e906d4bd2db476e6bb58ba to your computer and use it in GitHub Desktop.
Various MySQL tips / scripts
#!/bin/sh
#
# Auto discover and drop FKs:
#
mysql -s -e "select 'alter table ', table_name, ' drop foreign key ', constraint_name, ';' from information_schema.referential_constraints ;" > /tmp/disable_fk.sql
mysql -s < /tmp/disable_fk.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment