1set global innodb_file_per_table=1; 2CREATE TABLE ref_table1 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; 3CREATE TABLE ref_table2 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; 4CREATE TABLE `main` ( 5`id` int(11) NOT NULL AUTO_INCREMENT, 6`ref_id1` int(11) NOT NULL, 7`ref_id2` int(11) NOT NULL, 8PRIMARY KEY (`id`), 9UNIQUE KEY `idx_1` (`ref_id1`,`ref_id2`), 10KEY `FK_set_out_analysis_route_id` (`ref_id2`), 11CONSTRAINT `FK_1` FOREIGN KEY (`ref_id1`) REFERENCES `ref_table1` (`id`) , 12CONSTRAINT `FK_2` FOREIGN KEY (`ref_id2`) REFERENCES `ref_table2` (`id`) 13) ENGINE=InnoDB; 14SET FOREIGN_KEY_CHECKS=0; 15DROP INDEX `idx_1` ON `main`; 16SHOW TABLES; 17Tables_in_test 18main 19ref_table1 20ref_table2 21# restart 22ALTER TABLE `main` ADD INDEX `idx_1` (`ref_id1`); 23SHOW CREATE TABLE `main`; 24Table Create Table 25main CREATE TABLE `main` ( 26 `id` int(11) NOT NULL AUTO_INCREMENT, 27 `ref_id1` int(11) NOT NULL, 28 `ref_id2` int(11) NOT NULL, 29 PRIMARY KEY (`id`), 30 KEY `FK_set_out_analysis_route_id` (`ref_id2`), 31 KEY `idx_1` (`ref_id1`), 32 CONSTRAINT `FK_1` FOREIGN KEY (`ref_id1`) REFERENCES `ref_table1` (`id`), 33 CONSTRAINT `FK_2` FOREIGN KEY (`ref_id2`) REFERENCES `ref_table2` (`id`) 34) ENGINE=InnoDB DEFAULT CHARSET=latin1 35DROP TABLE main, ref_table1, ref_table2; 36