2012-10-09 82 views
0

我已經搜索了該問題,但找不到解決方案。錯誤1005 errno105

它是一個一到一個關係,我對此有一個FK的另一個表同樣的問題向工作人員

我不斷收到一個

error 1005 error no 105 

表結構

CREATE TABLE `staff` (
    `StaffNumber` varchar(5) NOT NULL, 
    `Firstname` varchar(45) DEFAULT NULL, 
    `Lastname` varchar(45) DEFAULT NULL, 
    `Insertion` varchar(45) DEFAULT NULL, 
    PRIMARY KEY (`StaffNumber`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 


CREATE TABLE `airmarshall` (
    `weaponNumber` int(11) NOT NULL, 
    `Nationality` varchar(45) NOT NULL, 
    `Snumber` varchar(5) NOT NULL, 
    `SnumberA` varchar(5) NOT NULL, 
    PRIMARY KEY (`Snumber`,`SnumberA`), 
    CONSTRAINT `staff_ibfk_1` FOREIGN KEY (`Snumber`) REFERENCES `staff` (`StaffNumber`)  
    ON DELETE CASCADE ON UPDATE CASCADE 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 
+0

適合我... – gks

+0

你在哪裏得到錯誤?添加一些相關信息 – gks

+0

當我添加airmarshall時,我得到它,因爲我收到的錯誤只是當我添加FK。 –

回答

0
In Mysql Server version: 5.1.60 


mysql> CREATE TABLE `staff` ( `StaffNumber` varchar(5) NOT NULL, `Firstname` varchar(45) DEFAULT NULL, `Lastname` varchar(45) DEFAULT NULL, `Insertion` varchar(45) DEFAULT NULL, PRIMARY KEY (`StaffNumber`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; 
    Query OK, 0 rows affected (0.15 sec) 


    mysql> CREATE TABLE `airmarshall` (
     -> `weaponNumber` int(11) NOT NULL, 
     -> `Nationality` varchar(45) NOT NULL, 
     -> `Snumber` varchar(5) NOT NULL, 
     -> `SnumberA` varchar(5) NOT NULL, 
     -> PRIMARY KEY (`Snumber`,`SnumberA`), 
     -> CONSTRAINT `staff_ibfk_1` FOREIGN KEY (`Snumber`) REFERENCES `staff` (`StaffNumber`)  
     -> ON DELETE CASCADE ON UPDATE CASCADE 
     -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 
    Query OK, 0 rows affected (0.16 sec) 

    mysql> show create table airmarshall; 
    -----------------------------------+ 
    | airmarshall | CREATE TABLE `airmarshall` (
     `weaponNumber` int(11) NOT NULL, 
     `Nationality` varchar(45) NOT NULL, 
     `Snumber` varchar(5) NOT NULL, 
     `SnumberA` varchar(5) NOT NULL, 
     PRIMARY KEY (`Snumber`,`SnumberA`), 
     CONSTRAINT `staff_ibfk_1` FOREIGN KEY (`Snumber`) REFERENCES `staff` (`StaffNumber`) ON DELETE CASCADE ON UPDATE CASCADE 
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |