在varchar列上创建外键时出现错误1215

时间:2016-09-27 19:12:28

标签: mysql

CREATE TABLE  `rajesh_testing`.`testing1` (
  `EMPLOYEE_NAME` varchar(25) NOT NULL,
  `EMPLOYEE_SALARY` decimal(14,0) NOT NULL,
  PRIMARY KEY (`EMPLOYEE_NAME`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


CREATE TABLE  `rajesh_testing`.`testing2` (
  `TEST2_ID` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
  `TEST2_EMPLOYEE_NAME` VARCHAR(25) NOT NULL,
  PRIMARY KEY (`TEST2_ID`),
  FOREIGN KEY (TEST2_EMPLOYEE_NAME) REFERENCES testing1(EMPLOYEE_NAME) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

创建表test2时遇到错误1215无法创建外键。

0 个答案:

没有答案