Monday, April 27, 2009

Error No:150 MySQL Solution with example

I was trying to create a foreign key using phpmyadmin. It was throwing an error :

ERROR 1005 (HY000): Can't create table '.\test1\ppe_job_time.frm' (errno: 150)

MySQL query was:

ALTER TABLE properties ADD FOREIGN KEY (fk_address_id) REFERENCES address(address_id);

After some trouble I found out that the table types were different.( i.e the properties table was type InnoDB and the address table was of type MyISAM. So I made sure that the table types were same and the problem was solved.

So make sure the table types are same, to avoid error No: 150 in MySQL

No comments: