Re: Remove - Foreign key constraint in innodb

2010-02-25 Thread Jim Lyons
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 vikkiatb...@yahoo.in 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


Re: Remove - Foreign key constraint in innodb

2010-02-25 Thread 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 vikkiatb...@yahoo.in  
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=arch...@jab.org