If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Forign key issue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-15-06, 03:15
venkat_lvr venkat_lvr is offline
Registered User
 
Join Date: Aug 2005
Posts: 19
Red face Forign key issue

Hi,

I'm using MYSQL 5.0.22 if I drop forign key constraint it cant deleted and also it doesn't give any errors

this is my code :

alter table <tablename> drop foreign key <fk name>;

pls give solution
Reply With Quote
  #2 (permalink)  
Old 07-15-06, 09:21
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
could you please do a SHOW CREATE TABLE for that table
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 07-17-06, 01:54
venkat_lvr venkat_lvr is offline
Registered User
 
Join Date: Aug 2005
Posts: 19
CREATE TABLE `cuntstates` (
`st_id` int(11) NOT NULL AUTO_INCREMENT,
`st_name` varchar(100) DEFAULT NULL,
`st_abb` varchar(2) DEFAULT NULL,
`st_cunt_abbr` char(2) NOT NULL,
`st_status` int(11) DEFAULT '1',
PRIMARY KEY (`st_id`),
KEY `fk_stat_cunt_abbr` (`st_cunt_abbr`),
CONSTRAINT `fk_st_cunt_abbr` FOREIGN KEY (`st_cunt_abbr`) REFERENCES `countries` (`ct_abbr`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

this is my Create table code

if i delete the Foriegn key fk_st_cunt_abbr it cant deleted

pls give solution
Reply With Quote
  #4 (permalink)  
Old 07-17-06, 05:28
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
could you show your ALTER statement too please
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 07-20-06, 05:47
venkat_lvr venkat_lvr is offline
Registered User
 
Join Date: Aug 2005
Posts: 19
alter table cuntstates drop foreign key fk_st_cunt_abbr;
Reply With Quote
  #6 (permalink)  
Old 07-20-06, 06:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
that looks like it should work

too bad you used the same name for the foreign key as for the index
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On