Remove - Foreign key constraint in innodb

Remove - Foreign key constraint in innodb

am 25.02.2010 13:03:57 von Vikram A

--0-937947547-1267099437=:21959
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi, I tried to remove foreign key constraint in innodb table. I t=
ried with different ways; but i am unable to drop the constraints. =0A=
http://lists.mysql.com/mysql/113053=0AIt says that, droping the foreign key=
constraint it is not possible in innodb engine. Is it so? or any othe=
r possibilities? I am using mysql 5.1.32 Please, Can any one you help =
me? Thank you VIKRAM A The INTERNET now has a pe=
rsonality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/
--0-937947547-1267099437=:21959--

Re: Remove - Foreign key constraint in innodb

am 25.02.2010 13:33:03 von Jim Lyons

--0016e6d7ee6ffed9d004806bfbe8
Content-Type: text/plain; charset=ISO-8859-1

Yes - you can drop a foreign key constraint, use the 'alter table ... drop
foreign key ...' command. If you get an error message, post the error
message.

On Thu, Feb 25, 2010 at 6:03 AM, Vikram A wrote:

> Hi,
>
> I tried to remove foreign key constraint in innodb table.
>
> I tried with different ways; but i am unable to drop the constraints.
>
>
> http://lists.mysql.com/mysql/113053
> It says that, droping the foreign key constraint it is not possible in
> innodb engine.
>
> Is it so? or any other possibilities? I am using mysql 5.1.32
>
> Please, Can any one you help me?
>
> Thank you
>
> VIKRAM A
>
>
>
> The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
> http://in.yahoo.com/




--
Jim Lyons
Web developer / Database administrator
http://www.weblyons.com

--0016e6d7ee6ffed9d004806bfbe8--

Re: Remove - Foreign key constraint in innodb

am 25.02.2010 14:15:48 von Jesper Wisborg Krogh

An example how to delete a foreign key from an InnoDB table:

test> CREATE TABLE table_1 (id int unsigned NOT NULL auto_increment
PRIMARY KEY) ENGINE=InnoDB;
Query OK, 0 rows affected (0.56 sec)

test> CREATE TABLE table_2 (table1_id int unsigned NOT NULL, FOREIGN
KEY (table1_id) REFERENCES table_1 (id)) ENGINE=InnoDB;
Query OK, 0 rows affected (0.11 sec)

test> SHOW CREATE TABLE table_2\G
*************************** 1. row ***************************
Table: table_2
Create Table: CREATE TABLE `table_2` (
`table1_id` int(10) unsigned NOT NULL,
KEY `table1_id` (`table1_id`),
CONSTRAINT `table_2_ibfk_1` FOREIGN KEY (`table1_id`) REFERENCES
`table_1` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.47 sec)

test> ALTER TABLE table_2 DROP FOREIGN KEY table_2_ibfk_1;
Query OK, 0 rows affected (0.11 sec)
Records: 0 Duplicates: 0 Warnings: 0

test> SHOW CREATE TABLE table_2\G
*************************** 1. row ***************************
Table: table_2
Create Table: CREATE TABLE `table_2` (
`table1_id` int(10) unsigned NOT NULL,
KEY `table1_id` (`table1_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

On 25/02/2010, at 11:33 PM, Jim Lyons wrote:

> Yes - you can drop a foreign key constraint, use the 'alter
> table ... drop
> foreign key ...' command. If you get an error message, post the error
> message.
>
> On Thu, Feb 25, 2010 at 6:03 AM, Vikram A
> wrote:
>
>> Hi,
>>
>> I tried to remove foreign key constraint in innodb table.
>>
>> I tried with different ways; but i am unable to drop the constraints.
>>
>>
>> http://lists.mysql.com/mysql/113053
>> It says that, droping the foreign key constraint it is not
>> possible in
>> innodb engine.
>>
>> Is it so? or any other possibilities? I am using mysql 5.1.32
>>
>> Please, Can any one you help me?
>>
>> Thank you
>>
>> VIKRAM A
>>
>>
>>
>> The INTERNET now has a personality. YOURS! See your Yahoo!
>> Homepage.
>> http://in.yahoo.com/
>
>
>
>
> --
> Jim Lyons
> Web developer / Database administrator
> http://www.weblyons.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org