MySQL Forums
Forum List  »  Newbie

Altering a table to add a foreign key
Posted by: Sage Adams
Date: August 04, 2005 04:50PM

I've already created my two tables I want to be related. Now I need to relate them. Would anyone please show me how to create a foreign key on a table that has already been created?

I tried the following syntax and got an error in MySQL Monitor:

mysql> alter table Main foreign key (Department) references Department(DepartmentID);

Help! : )

S./

Website:
http://www.villainsvalley.net/

Options: ReplyQuote


Subject
Written By
Posted
Altering a table to add a foreign key
August 04, 2005 04:50PM


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.