Mysql create table with multiple foreign key on delete set null

后端 未结 4 1793
粉色の甜心
粉色の甜心 2021-01-12 05:59

I am trying to create a database with multiple foreign keys with delete/ update constraints, but I got a error code 1005 with following sql scripts:

CREATE T         


        
4条回答
  •  再見小時候
    2021-01-12 06:17

    Visit :

    http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html

    CREATE TABLE `ffxi_characterJob` (
    `serverID` int(11) NOT NULL,
    `userid` int(10)unsigned NOT NULL,
    `characterName` varchar(255) NOT NULL,
    `jobAbbr` char(4) NOT NULL,
    `jobLevel` int(11) default '0',
    PRIMARY KEY (`serverID`,`userid`,`characterName`,`jobAbbr`),
    INDEX (`jobAbbr`),
    CONSTRAINT FOREIGN KEY (`serverID`,`userid`,`characterName`) REFERENCES `ffxi_characters` (`serverID`,`userid`,`characterName`) 
    ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT FOREIGN KEY (`jobAbbr`) REFERENCES `ffxi_jobType` (`jobAbbr`) ON DELETE CASCADE ON UPDATE CASCADE
    ) TYPE=InnoDB;
    

提交回复
热议问题