MySQL Forums
Forum List  »  InnoDB

Re: ERROR 1005: Can't create table (errno: 150)
Posted by: banaz kaki
Date: May 05, 2009 02:52PM

Hi!
I have read all of the inputs here regarding this 150 error, bur I cannot find a soluition to my problem. I use server version 5.0.41 and phpmyadmin version 2.10.1. The datatype of the attribute ID in the table Alternativ is the same as in the tables EttAlternativ and FleraAlternativ, IN(11) NOT NULL.The engine type is InnoDB, the three of them are not UNSIGNED and I eaven tried to create an index on the foreign key in the referencin tables. I´ll be very glad for any recomendations I can get to try.Here is my SQL statments:

Creation of table nr1:

CREATE TABLE Alternativ (FrageTypKod VARCHAR (50) NOT NULL ,
ID INT(11) NOT NULL) ENGINE=INNODB;

ALTER TABLE Alternativ ADD
CONSTRAINT PK_Alternativ
PRIMARY KEY (FrageTypKod,ID);

ALTER TABLE Alternativ ADD
CONSTRAINT FK_alternativ_fragetyp
FOREIGN KEY (FrageTypKod)
REFERENCES FrageTyp(Kod) ON UPDATE CASCADE ON DELETE CASCADE;

Cration of table nr2:
CREATE TABLE EttAlternativ (FrageTypKod VARCHAR (50) NOT NULL ,
AlternativID INT (11) NOT NULL,
SvarFrageNr INT (11) NOT NULL ,
SvarPersonRaknare INT (11) NOT NULL,
SvarOmradeNr VARCHAR (2) NOT NULL) ENGINE=INNODB;

ALTER TABLE EttAlternativ ADD
CONSTRAINT PK_EttAlternativ
PRIMARY KEY (SvarFrageNr,SvarPersonRaknare,SvarOmradeNr);

ALTER TABLE EttAlternativ ADD
CONSTRAINT FK_EttAlternativ
FOREIGN KEY (SvarFrageNr,SvarPersonRaknare,SvarOmradeNr)
REFERENCES Svar(FrageNr, PersonRaknare, OmradeNr)
ON UPDATE CASCADE ON DELETE CASCADE;

ALTER TABLE EttAlternativ ADD
CONSTRAINT FK_EttAlternativ_fragetyp
FOREIGN KEY (FrageTypKod)
REFERENCES FrageTyp(Kod) ON UPDATE CASCADE ON DELETE CASCADE;



I get the erro: 150 when I run this statment to crate an FK:

ALTER TABLE EttAlternativ ADD
CONSTRAINT FK_EttAlternativ_alt
FOREIGN KEY (AlternativID)
REFERENCES Alternativ(ID) ON UPDATE CASCADE ON DELETE CASCADE;

The erro I get is:#1005 - Can't create table '#sql-1801a_502d374.frm' (errno: 150)

Please help me see the problem...

Options: ReplyQuote


Subject
Views
Written By
Posted
644450
March 24, 2005 01:20PM
5075
October 09, 2012 09:48PM
3380
December 19, 2011 10:13PM
8778
May 09, 2006 06:01PM
7977
November 15, 2006 02:05PM
7025
T D
February 01, 2008 06:47AM
8831
August 27, 2008 08:08AM
9362
December 03, 2008 10:15AM
5803
May 01, 2009 07:39AM
Re: ERROR 1005: Can't create table (errno: 150)
6477
May 05, 2009 02:52PM
3039
August 29, 2011 04:46PM
4641
s l
December 15, 2009 01:48PM
4615
December 22, 2009 02:54AM
2893
February 18, 2011 08:55AM
3455
May 24, 2011 10:11AM


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.