Skip to content

Instantly share code, notes, and snippets.

@dsueiro
Created August 9, 2011 11:01
Show Gist options
  • Select an option

  • Save dsueiro/1133763 to your computer and use it in GitHub Desktop.

Select an option

Save dsueiro/1133763 to your computer and use it in GitHub Desktop.
select concat('alter table `', table_name ,'` add constraint `', constraint_name, '` foreign key (`', column_name ,'`) references `', referenced_table_name , '` (`',referenced_column_name,'`)') from information_schema.key_column_usage where table_schema = 'siic_v2' and constraint_name not like 'PRIMARY%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment