mysql - How do I generate ADD FOREIGN KEY statements for a group of tables? -
I am using MySQL 5.5.37. Looking at a group of tables, (table_a, table_b, ..., table_n), how do I write a SQL statement (or process) that will generate SQL which produces all the tables that these tables link? Note that although I can run a "mysqldump" that will generate the "created table" statement with the "concert" sections, I only want the statements that will add the foreign key, such as
< code> optional table table_a ADD FOREIGN key (PIID) Reference table_x (P_ID)Thanks, - Dave
SELECT CONCAT ('optional table', table_name, 'add foreign key (', ban_name, ')', 'context B ', referenced_ table_name,' (', referenced_column_name,'); 'AS) information_schema .key_column_usage from alter_cmd WHERE is not referenced_ table_name;
Comments
Post a Comment