Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2005
    Posts
    19

    Red face Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    could you please do a SHOW CREATE TABLE for that table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    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

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    could you show your ALTER statement too please
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Aug 2005
    Posts
    19
    alter table cuntstates drop foreign key fk_st_cunt_abbr;

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    that looks like it should work

    too bad you used the same name for the foreign key as for the index
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •