On Thu, Jul 22, 2010 at 9:09 AM, John Daisley <daisleyj...@googlemail.com>wrote:

> Sorry, my bad! Must learn to read the whole message!!
>
>
> This can be caused because when a foreign key is created mysql adds an
> index key to the column in addition to the foreign key. Why I'm not sure,
> but I'm guessing its for performance. To drop this foreign key
>
> First do this to get the index names
>
>
> SHOW CREATE TABLE `table_name`
>
> Which will give an output something like this
>
>
> | table_name | CREATE TABLE `table_name` (
>   `id` int(10) unsigned NOT NULL auto_increment,
>   `idx` int(5) unsigned NOT NULL,
>   KEY `key_column` (`idx`),
>   CONSTRAINT `table_name_ibfk_1` FOREIGN KEY (`idx`) REFERENCES
> `second_table` (`id`) ON DELETE SET NULL
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
>
>
> So, first you remove the key:
>
>
> ALTER TABLE table_name DROP KEY `idx`;
>
>
> then the foreign key:
>
>
> ALTER TABLE table_name DROP FOREIGN KEY `table_name_ibfk_1`;
>
>
> Then that should do it!
>

Thank you!
V

Reply via email to