ALTER TABLE `your_referencing_table` DROP FOREIGN KEY `your_existing_fk_name`; ALTER TABLE `your_referencing_table` CHANGE `existing_field_name` `new_field_name` INT( 11 ) UNSIGNED NULL DEFAULT NULL COMMENT 'fk'; ALTER TABLE `your_referencing_table` DROP INDEX `existing_index_name`, ADD INDEX `new_index_name` (`new_field_name`); ALTER TABLE `your_referencing_table` ADD CONSTRAINT `your_new_fk_name` FOREIGN KEY (`new_field_name`) REFERENCES `your_existing_reference_table` (`your_existing_reference_table_field`) ON DELETE CASCADE ON UPDATE CASCADE;
Thursday, April 11, 2013
What's the MySQL process/syntax for renaming a field that's wired up as a foreign key?
Subscribe to:
Post Comments (Atom)
About Me
- John Erck
- I code. I figured I should start a blog that keeps track of the many questions and answers that are asked and answered along the way. The name of my blog is "One Q, One A". The name describes the format. When searching for an answer to a problem, I typically have to visit more than one site to get enough information to solve the issue at hand. I always end up on stackoverflow.com, quora.com, random blogs, etc before the answer is obtained. In my blog, each post will consist of one question and one answer. All the noise encountered along the way will be omitted.
Blog Archive
-
▼
2013
(49)
-
▼
April
(12)
- How do I set up Apache virtual hosts on a Debian b...
- How do I install git and link my Linux machine to ...
- What's the best place to look for how to manage an...
- How do I set up ssh keys and turn off password acc...
- How do I install the latest versions of Apache, My...
- How do I install mysql-client, mysql-server, and l...
- How do I set up a Next Generation Rackspace Cloud ...
- What's the MySQL process/syntax for renaming a fie...
- What's the MySQL syntax for dropping a foreign key?
- What's the MySQL syntax for adding a foreign key?
- How do I smooth the edges of a selection using Pho...
- How do I revert all local changes in a git repo?
-
▼
April
(12)
No comments:
Post a Comment