MySQL Forums
Forum List  »  InnoDB

Foreign Keys Dont Work
Posted by: Kalkota Raja Mohan Reddy
Date: January 06, 2005 11:34PM

I am Using the Version "mysql-4.0.20d-win" on my Computer. But i am not able to Add or Insert a Foreign key.

My Query is like this:
DROP TABLE IF EXISTS `dept1`;

CREATE TABLE `dept1` (
`Dept_ID` int(5) NOT NULL default '0',
`Dept_Name` varchar(50) NOT NULL default '',
`Dept_Desc` varchar(150) default NULL,
PRIMARY KEY (Dept_ID)
)
ENGINE=InnoDB;


DROP TABLE IF EXISTS `master`;

CREATE TABLE `master` (
`Admission_ID` int(11) NOT NULL default '0',
`Adm_Start_Date` datetime NOT NULL default '0000-00-00 00:00:00',
`Adm_End_Date` datetime default NULL,
`Admission_Class` varchar(20) default NULL,
`Dept_ID` int(11) NOT NULL default '0',
`Ward_No` int(11) default '0',
PRIMARY KEY (Admission_ID),
CONSTRAINT 'admission_dept' FOREIGN KEY (Dept_ID) REFERENCES dept1(Dept_ID) ON DELETE SET NULL
)
ENGINE=InnoDB;


I get this Error:
[root@localhost:3306] ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''admission_dept' FOREIGN KEY (Dept_ID) REFERENCES dept1(Dept_ID) ON DELETE SET NULL


Can u help me out in this situation?

Options: ReplyQuote


Subject
Views
Written By
Posted
Foreign Keys Dont Work
4061
January 06, 2005 11:34PM
2510
January 07, 2005 03:58PM
2556
January 12, 2005 01:49AM
2434
January 09, 2005 07:15PM
2476
January 10, 2005 05:02PM
2418
January 12, 2005 05:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.