Remove a foreign key constraint from a table.
Section: constraints and keys
Drop a foreign key
sql
sql
ALTER TABLE orders DROP FOREIGN KEY fk_orders_user;Explanation
You may also need to drop the supporting index separately if you no longer need it.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing constraints and keys
Create a table with a foreign key
Reference a parent table and enforce relational integrity.
Create a table with a composite primary key
Use multiple columns as the logical primary key.
Create a users table
Create a table with an auto-increment primary key and timestamps.