0

我正在尝试使用以下 sql 在 Mysql 数据库中创建表

   CREATE  TABLE IF NOT EXISTS `dev_dict`.`TAMILWORD_SECONDARY` (
    `ID` INT NOT NULL ,
    `TAMILWORD_ID` INT NOT NULL ,
    `WORDS` VARCHAR(50) NOT NULL ,
    `CREATED_DTTM` TIMESTAMP NOT NULL ,
    `MODIFIED_DTTM` TIMESTAMP NOT NULL ,
     PRIMARY KEY (`ID`) ,
       UNIQUE INDEX `WORDS_UNIQUE` (`WORDS` ASC, `TAMILWORD_ID` ASC) ,
       INDEX `FK_TAMILWORD_ID_idx` (`TAMILWORD_ID` ASC) ,
     CONSTRAINT `FK_TAMILWORD_ID`
       FOREIGN KEY (`TAMILWORD_ID` )
       REFERENCES `dev_dict`.`TAMILWORD` (`ID` )
       ON DELETE NO ACTION
     ON UPDATE NO ACTION)
    ENGINE = InnoDB

但得到错误代码:1022。无法写入;表“tamilword_secondary”中的重复键。

谢谢你帮助我..我已经有泰米尔语表了,并且得到了同样的错误

   CREATE  TABLE IF NOT EXISTS `dev_dict`.`TAMILWORD` (
     `ID` INT NOT NULL ,
     `WORD` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL ,
     `SENTENCE` VARCHAR(100) NULL ,
     `CREATED_DTTM` TIMESTAMP NOT NULL ,
    `MODIFIED_DTTM` TIMESTAMP NOT NULL ,
     PRIMARY KEY (`ID`) ,
        INDEX `SECONDARY` (`WORD` ASC, `SENTENCE` ASC) )
     ENGINE = InnoDB
4

1 回答 1

0

先建dev_dict.TAMILWORD表。除此之外,您的陈述有效。

请参阅SQL Fiddle 示例

于 2013-03-13T05:17:11.253 回答