[英]Cannot alter the table to set a foreign key
When I am trying to add a foreign key to my column I am getting an error. 当我尝试向列添加外键时,出现错误。 Please let me know what is wrong with it.
请让我知道它有什么问题。
ALTER TABLE address
ADD CONSTRAINT FK_employeeid
FOREIGN KEY (employeeid) REFERENCES newdb(employeeid);
Error: 错误:
1005 - Can't create table
mydb
.1005-无法创建表
mydb
。#sql-1cc_564
(errno: 150 "Foreign key constraint is incorrectly formed")#sql-1cc_564
(错误号:150“外键约束#sql-1cc_564
不正确”)
My impression is that newdb
is a schema name and not a table name. 我的印象是
newdb
是架构名称,而不是表名称。 I would expect something like 我希望有类似的东西
ALTER TABLE address
ADD CONSTRAINT FK_employeeid
FOREIGN KEY (employeeid) REFERENCES newdb.Employees(employeeid);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.