Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.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 无法更改表以设置外键_Mysql_Sql_Foreign Keys - Fatal编程技术网

Mysql 无法更改表以设置外键

Mysql 无法更改表以设置外键,mysql,sql,foreign-keys,Mysql,Sql,Foreign Keys,当我试图将外键添加到我的列时,我得到了一个错误。请告诉我有什么问题 ALTER TABLE address ADD CONSTRAINT FK_employeeid FOREIGN KEY (employeeid) REFERENCES newdb(employeeid); 错误: 1005-无法创建表mydb\sql-1cc_564(错误号:150“外键约束格式不正确”) 我的印象是newdb是一个模式名,而不是表名。 我期待着类似的事情 ALTER TABLE address ADD CO

当我试图将外键添加到我的列时,我得到了一个错误。请告诉我有什么问题

ALTER TABLE address
ADD CONSTRAINT FK_employeeid
FOREIGN KEY (employeeid) REFERENCES newdb(employeeid);
错误:

1005-无法创建表
mydb
\sql-1cc_564
(错误号:150“外键约束格式不正确”)


我的印象是
newdb
是一个模式名,而不是表名。 我期待着类似的事情

ALTER TABLE address
ADD CONSTRAINT FK_employeeid
FOREIGN KEY (employeeid) REFERENCES newdb.Employees(employeeid);

我们可以看看你的
CREATE TABLE
语句吗?我是从phpmyadmin创建的。你真的有一个名为newdb的表吗?是的,我有该DB中的所有数据。我不熟悉它,但你确定你的
employeeid
和你的
newdb(employeeid)
共享同一类型吗?