Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 错误1005:Can';不创建表_Mysql_Sql - Fatal编程技术网

Mysql 错误1005:Can';不创建表

Mysql 错误1005:Can';不创建表,mysql,sql,Mysql,Sql,在我遇到这个问题之前,我正试图放下一张桌子 并成功地解决了,但现在我试图放下桌子,结果出现了以下错误: ERROR: Error 1005: Can't create table 'radiotaxi_final.#sql-108_28' (errno: 150) 声明: ALTER TABLE `RadioTaxi_Final`.`DireccionConductor` CHANGE COLUMN `Conductor_cedula` `Conductor_cedula` INT(11) N

在我遇到这个问题之前,我正试图放下一张桌子

并成功地解决了,但现在我试图放下桌子,结果出现了以下错误:

ERROR: Error 1005: Can't create table 'radiotaxi_final.#sql-108_28' (errno: 150)
声明:

ALTER TABLE `RadioTaxi_Final`.`DireccionConductor` CHANGE COLUMN `Conductor_cedula` `Conductor_cedula` INT(11) NOT NULL  , 

  ADD CONSTRAINT `fk_DireccionConductor_Conductor1`

  FOREIGN KEY (`Conductor_cedula` )

  REFERENCES `RadioTaxi_Final`.`Conductor` (`cedula` )

  ON DELETE NO ACTION

  ON UPDATE NO ACTION
结果是:

SQL script execution finished: statements: 11 succeeded, 1 failed
下表:

CREATE TABLE `conductor` (  `cedula` int(10) unsigned NOT NULL,  `apellidos` varchar(30) COLLATE utf8_spanish2_ci NOT NULL,  `nombres` varchar(30) COLLATE utf8_spanish2_ci NOT NULL,  `fechaNacimiento` date NOT NULL,  PRIMARY KEY (`cedula`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci

创建
外键时,引用列和引用列的数据类型必须完全相同。在参考表中,
conductor.cedula
的类型为
INT(10)UNSIGNED
。您已尝试在
DireccionConductor.Conductor\u cedula
上创建FK作为
INT(11)
,隐式
签名
。按如下方式修改语句,使类型匹配:

ALTER TABLE `RadioTaxi_Final`.`DireccionConductor`
  /* INT(10) UNSIGNED type matches the referenced table */
  CHANGE COLUMN `Conductor_cedula` `Conductor_cedula` INT(10) UNSIGNED NOT NULL  , 
  ADD CONSTRAINT `fk_DireccionConductor_Conductor1`
    FOREIGN KEY (`Conductor_cedula` )
    REFERENCES `RadioTaxi_Final`.`Conductor` (`cedula` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION

150是外键创建错误。请发布
RadioTaxi\u Final.Conductor
表。谢谢,它工作正常,但如下所示:ALTER table
RadioTaxi\u Final
DireccionConductor
/*INT(10)UNSIGNED类型匹配引用的表*/CHANGE列
Conductor\u cedula
Conductor\u cedula
INT(10)UNSIGNED NOT NULL,添加关于删除时无操作更新时无操作的外键(
Conductor\u cedula
)引用的约束