Skip to content

Instantly share code, notes, and snippets.

@SteGriff
Created September 26, 2018 09:30
Show Gist options
  • Select an option

  • Save SteGriff/e458217ba2a0f84afd1e52f04a56cd88 to your computer and use it in GitHub Desktop.

Select an option

Save SteGriff/e458217ba2a0f84afd1e52f04a56cd88 to your computer and use it in GitHub Desktop.
Generate DROP statements for FK constriants
select
concat('alter table ', table_name, ' drop foreign key ', constraint_name, ';')
from
information_schema.key_column_usage
where
referenced_table_name is not null
and table_schema = 'MyTableName';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment