Realmente odio usar el tiempo de otras personas, pero parece que el problema simplemente no desaparece.No se puede crear la tabla (errno: 150) InnoDB añadiendo restricciones de clave externa
Consideré todas las recomendaciones en http://verysimple.com/2006/10/22/mysql-error-number-1005-cant-create-table-mydbsql-328_45frm-errno-150/ y en http://forums.mysql.com/read.php?22,19755,19755#msg-19755 pero nada.
espero que alguien señale un error estúpido.
aquí son las tablas: Código
CREATE TABLE IF NOT EXISTS `shop`.`category` (
`id` INT(11) NOT NULL AUTO_INCREMENT ,
`category_id` INT(11) NOT NULL ,
`parent_id` INT(11) NULL DEFAULT '0' ,
`lang_id` INT(11) NOT NULL ,
...other columns...
PRIMARY KEY (`id`, `category_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `shop`.`product_category` (
`category_id` INT(11) NOT NULL ,
`product_id` INT(11) NOT NULL ,
INDEX `fk_product_category_category1_zxc` (`category_id` ASC) ,
CONSTRAINT `fk_product_category_category1_zxc`
FOREIGN KEY (`category_id`)
REFERENCES `shop`.`category` (`category_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
de error: 1005. No se puede crear la tabla 'shop.product_category' (Error: 150)
Gracias! ¡Esto resolvió el problema! –
Si esto resolvió el problema, ¡marque la respuesta como aceptada! – ddinchev
Disculpa, ¿cómo hago eso? –