I created my MySQL schema that consists of multiple tables and I decided that I would add the foreign key constraints afterwards for each table, using the command:
ALTER TABLE Orders
ADD FOREIGN KEY (P_Id)
REFERENCES Persons(P_Id)
How can I get a backup of the schema (containing the foreign keys) so that I can duplicate it in another machine?
Note that SHOW CREATE TABLE and mysqldump do not work in my case because they only create a UNIQUE KEY constraint and not a FOREIGN KEY.
解决方案
mysqldump create the dump of foreign keys as well...
it adds syntax like:
mysql> SET foreign_key_checks = 0;
mysql> SOURCE dump_file_name;
mysql> SET foreign_key_checks = 1;