How to drop a Foreign Key in mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • santhanalakshmi
    New Member
    • May 2009
    • 147

    How to drop a Foreign Key in mysql

    Hi,
    I cant able to drop the foreign key from the table

    Code:
    [B]mysql> alter table stuprmst drop foreign key;
    ERROR 1005 (HY000): Can't create table 'test.#sql-8b4_2' (errno: 150)
    [/B]
    help me out ...thanks
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    You should specify the constraint name of the foreign key you want to drop. If you did not define it yourself, or do not know the name, use the SHOW CREATE TABLE command to review the actual CREATE TABLE statement used to create your table. The constraint name will be displayed there, even if you left it up to MySQL to generate it for you.

    See 13.6.4.4. FOREIGN KEY Constraints for more details.

    Comment

    Working...