Jesse, a stab in the dark here, with some info from the manual.

A foreign key constraint is in My Code erroneously coded,
If MySQL gives the error number 1005 from a CREATE TABLE
statement, and the error message string refers to errno 150, then
the 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. Starting from version 4.0.13, you can
use SHOW INNODB STATUS to look at a detailed explanation of the
latest InnoDB foreign key error in the server.

You explicitly specify the database of one table with
ALTER TABLE `karate`.`custpoints`
but later you don't explicitly specify the database of the other with:
REFERENCES `custtournaments` (`ID`)

Is it possible you're in the wrong database (different from
'custtournaments') when you issue this command?

Also check out  SHOW INNODB STATUS for more info on what might be going on.

HTH,
Dan


On 7/19/06, Jesse <[EMAIL PROTECTED]> wrote:
I'm using MySQL 5 with InnoDB tables.  I'm trying to create a foreign key,
but when I try, it's giving me an error.  I've tried this with the
MySQLQuery Browser, and EMS SQL Manager 2005.  I get the following error in
the Query Browser:

Error while executing query.

ALTER TABLE `karate`.`custpoints` ADD CONSTRAINT `FK_custpoints_1` FOREIGN
KEY `FK_custpoints_1` (`CTID`)
REFERENCES `custtournaments` (`ID`)
ON DELETE CASCADE
ON UPDATE RESTRICT;

MySQL Error Number 1005
Can't create table '.\karate\#sql-304_9.frm' (errno: 150)

Any idea why this is happening, and how to fix it?

Thanks,
Jesse


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to