[SOLVED] Altering a foreign key

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

[SOLVED] Altering a foreign key

Post by Rovas »

When I created the structure of my MySQL database I chose to ignore the clause ON DELETE ... BIG mistake :oops: :(
Now I have to modify a number of foreign key to include this. I tried the ALTER COLUMN, MODIFY, but they didn' t work. I' m thinking of saving the data in the tables, droping the tables and create them again the right way. I' m not going to do this unless there won' t be other options.
Do you have any other ideas.
Last edited by Rovas on Wed Jan 10, 2007 3:08 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I think you're after...

Code: Select all

ALTER TABLE tableName CHANGE oldColumn newColumnDefinition
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

Solved it using

Code: Select all

DELETE table_name.* IGNORE KEYS FROM table_name;
Post Reply