cannot create foreign key in mySql

G

Gaurav

hi.
I have got two tables with me namely "resources" and "instance"
now structure of "resources" is :
------------------------------­------
r_name varchar(50) primary key,
------------------------------­------


the structure of "instance" is :
------------------------------­------
instance_name varchar(50) primary key,
qty int(5),
no_allocated int(5),
r_name varchar(50)
------------------------------­--------


now when i want to make the "r_name" of instance table as the foreign
key to the "resources table"


i use the followin command :


ALTER TABLE INSTANCE ADD FOREIGN KEY (R_NAME) REFERENCES
RESOURCES(R_NAME);


the error generated is :


" ERROR 1005 (HY000) : Can't create table
'.\brocade_lab\#sql-650-f7.frm­' (errno : 150)


what should i do ?


regards
gaurav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top