Archbold,
Thursday, July 18, 2002, 12:18:09 AM, you wrote:

A> I'm having a problem dropping a foreign key constraint from an Innodb table. I am 
using MySQL 3.23.51 for Win32.  Any help would be greatly appreciated....

A>  I have a simple set up like the one below:

A> CREATE TABLE mastertable
A> (
A> masterkey INT NOT NULL PRIMARY KEY AUTO_INCREMENT
A> ) TYPE=innodb;

A> CREATE TABLE othertable
A> (
A> otherkey INT NOT NULL PRIMARY KEY AUTO_INCREMENT
A> masterkey INT NOT NULL,
A> INDEX (masterkey),
A> FOREIGN KEY (masterkey) REFERENCES mastertable (masterkey) ON DELETE CASCADE
A> ) TYPE=innodb;

A> Which works fine and all.  However, if I go to remove a foreign key it won't let me 
- though it does not report any errors:
A> ALTER TABLE othertable DROP FOREIGN KEY masterkey;

A> I tried dropping the column entirely (which is what I'm aiming to do in the first 
place) and dropping the index, but Innodb won't let me do either of those because of 
the foreign key
A> constraints.

A> I've also tried setting the table to a MyISAM type, removing the constraints, index 
and column then setting it back to an Innodb table.  No go there either.  It wants 
that field and index in
A> the table before it will change the type back to Innodb.

A> So, how does one go about removing the foreign key constraint once it is in place?

Use DROP TABLE and then CREATE TABLE to remove foreign key
constraints.





-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to