Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#1005 - Can't create table (errno: 150)

Status
Not open for further replies.

akgta

Programmer
Jul 18, 2007
42
CA
Hello,

I am getting the error message:
#1005 - Can't create table './wagconsulting/job_hr_contact_disp_yn.frm' (errno: 150)

I am using MySQL 5.0.37-log

The Primary Key table definition is:
----------------------------------------------------------------------
create table job
(
job_id mediumint unsigned auto_increment,
job_title varchar (120) not null,
job_desc text not null,
primary key (job_id),
) type=innodb;

----------------------------------------------------------------------


And the Foreign Ket table definition is:
----------------------------------------------------------------------
create table job_hr_contact_disp_yn
(
job_id mediumint unsigned not null,
emp_name char (1),
email char (1),
index jhr_contacts_disp_index (job_id),
foreign key (job_id) references job (job_id) on delete cascade
) type=innodb;
----------------------------------------------------------------------

The datatypes for the PK and FK are exactly the same.

I also tried by removing the index clause from the FK table, but still getting the same error message.

Your kind help is highly appreciated
Best Regards,
Amir Khan
 

"If MySQL reports an error number 1005 from a CREATE TABLE statement, and the error message refers to errno 150, table creation failed because a foreign key constraint was not correctly formed. Similarly, if an ALTER TABLE fails and it refers to errno 150, that means a foreign key definition would be incorrectly formed for the altered table. You can use SHOW ENGINE INNODB STATUS to display a detailed explanation of the most recent InnoDB foreign key error in the server.
 
you appear to be running an entire script, and therefore you are not seeing the error in the first table

you have a dangling comma in front of the closing parenthesis for the job table





r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top