I have create two tables with reference with another table:
I like this:
Table1:
CREATE TABLE species
(
id TINYINT NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
PRIMARY KEY(id)
) ENGINE=INNODB;
Table2 (Reference of the above table)
CREATE TABLE zoo
(
id INT(4) NOT NULL,
name VARCHAR(50) NOT NULL,
FK_species TINYINT(4) NOT NULL,
INDEX (FK_species),
FOREIGN KEY (FK_species) REFERENCES species (id),
PRIMARY KEY(id)
) ENGINE=INNODB;
Than its automatically create an index for the FOREIGN KEY for FK_species in zoo table.
Now I am try to delete the Index of the zoo table:
ALTER TABLE zoo DROP INDEX FK_species;
Its showing the following MySQL error.
Error on rename of '.\test\#sql-1ec_9d' to '.\test\zoo' (errno: 150)
From FOREIGN KEY Constraints @ dev.mysql.com: