I have a table that looks like so:
CREATE TABLE `countrytable` (
`countryCode` varchar(2) NOT NULL DEFAULT '',
`currencyCode` varchar(3) NOT NULL,
`currencySymbol` varchar(4) NOT NULL DEFAULT '',
`currencyIsRight` tinyint(4) DEFAULT '0',
`currencyName` varchar(45) DEFAULT 'US Dollar',
`countryName` varchar(50) DEFAULT NULL,
PRIMARY KEY (`countryCode`,`currencyCode`),
UNIQUE KEY `countryCode_UNIQUE` (`countryCode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I am trying to create another table, which has a foreign key on countrytable.currencyCode. I keep getting the following error:
The specified relation was unable to be created.
MySQL said: Can't create table 'noteitdb.#sql-b8_13' (errno: 150)
The data types of the two columns exactly match. What could I be missing?
currencyCode should be indexed first. Refer MySQL docs.