缺少约束索引

时间:2015-01-07 11:45:01

标签: mysql sql database

获取此错误 - “无法添加外键约束。在引用的表'transcriptionservices'中缺少约束'FK_transcriptionServiceName'的索引”

我搜索谷歌无济于事。有什么想法吗?

这是SQL:

CREATE TABLE transcriptionConfig (
  id BIGINT,
  transcriptionEnabled BOOLEAN,
  PRIMARY KEY(id),
  CONSTRAINT `FKUSER` FOREIGN KEY (id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=ndb;


CREATE TABLE transcriptionServices (
  id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(80) NOT NULL,
  URL VARCHAR(80) NOT NULL
) ENGINE=ndb AUTO_INCREMENT=0;


ALTER TABLE transcriptionConfig
  ADD `serviceName` VARCHAR(80) NOT NULL;


ALTER TABLE transcriptionConfig
  ADD CONSTRAINT FK_transcriptionServiceName
  FOREIGN KEY (serviceName) REFERENCES transcriptionServices(name)
  ON DELETE CASCADE;

0 个答案:

没有答案