Home > MySQL > Modify Foreign Key

Modify Foreign Key

April 6th, 2009

To modify a Foreign Key in MySQL follow this steps :
1) Show table to see what is the name of Foreign Key we want to delete

SHOW CREATE TABLE table

2) Delete the Foreign Key

ALTER TABLE table DROP FOREIGN KEY table_ibfk_x

3) Create the new Foreign Key

ALTER TABLE table ADD CONSTRAINT `table_ibfk_x` FOREIGN KEY (`Field_id`) REFERENCES `references_table` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION

MySQL ,

  1. May 6th, 2009 at 14:45 | #1

    Hi, interesting post. I have been pondering this topic,so thanks for posting. I will likely be subscribing to your posts. Keep up the good posts

  2. June 13th, 2009 at 01:11 | #2

    Great post! I’ll subscribe right now wth my feedreader software!

  3. June 14th, 2009 at 01:30 | #3

    The article is usefull for me. I’ll be coming back to your blog.

  4. June 15th, 2009 at 09:01 | #4

    Original post by Dmitri Gromov

  5. June 16th, 2009 at 02:34 | #5

    You know so many interesting infomation. You might be very wise. I like such people. Don’t top writing.

  6. July 18th, 2009 at 22:48 | #6

    Great post, thanks for sharing this with me :)

    I look forward to reading your future posts!

  7. Gayatri
    November 24th, 2009 at 10:52 | #7

    Great Post, helped me out.

  1. No trackbacks yet.