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
.#sql-1cc_564
(errno: 150 "Foreign key constraint is incorrectly formed")
My impression is that newdb
is a schema name and not a table name. I would expect something like
ALTER TABLE address
ADD CONSTRAINT FK_employeeid
FOREIGN KEY (employeeid) REFERENCES newdb.Employees(employeeid);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.