How to Remove Foreign Key Syntax in MySQL
Foreign keys link tables in your MySQL database. You use a foreign key to link to a primary key in another table. This lets you retrieve a list of data from multiple tables. For instance, you can query for a customer and link an orders table to retrieve the customer's orders. The primary key is the same value as the foreign key, so MySQL can link the two tables. When you no longer need to link a table, delete the foreign key.
Instructions
-
-
1
Click the Windows "Start" button and select All Programs. Click MySQL, then Query Browser.
-
2
Connect to the database in the opened wizard window. Type your user name, password and database server name in the window to connect.
-
-
3
Type the following code to delete the foreign key:
alter table table_name drop foreign key key_name
Replace "table_name" with the name of your own MySQL table. Replace "key_name" with the name of the key for the column. You can have more than one foreign key in a table.
-
4
Click the "Execute" button in the Query Browser toolbar. The SQL query executes and the key is removed from the table.
-
1