

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we remove FOREIGN KEY constraint from a column of an existing MySQL table?
We can remove FOREIGN KEY constraint from a column of an existing table by using DROP keyword along with ALTER TABLE statement.
Syntax
ALTER TABLE table_name DROP FOREIGN KEY constraint_name
Here constraint name is the name of foreign key constraint which we applied while creating the table. If no constraint name is specified then MySQL will provide constraint name which can be checked by SHOW CREATE TABLE statement.
Example
The following query will delete the FOREIGN KEY constraint from ‘orders’ table −
mysql> Alter table orders DROP FOREIGN KEY orders_ibfk_1; Query OK, 0 rows affected (0.22 sec) Records: 0 Duplicates: 0 Warnings: 0
- Related Questions & Answers
- How can we remove PRIMARY KEY constraint from a column of an existing MySQL table?
- How can we add a FOREIGN KEY constraint to the field of an existing MySQL table?
- How can we remove NOT NULL constraint from a column of an existing MySQL table?
- How can we remove composite PRIMARY KEY constraint applied on multiple columns of an existing MySQL table?
- How can we apply a NOT NULL constraint to a column of an existing MySQL table?
- How can we apply the PRIMARY KEY constraint to the field of an existing MySQL table?
- How can we remove a column from MySQL table?
- Can we remove a primary key from MySQL table?
- How can we assign FOREIGN KEY constraint on multiple columns?
- How can we apply UNIQUE constraint to the field of an existing MySQL table?
- How can I drop an existing column from a MySQL table?
- How can we drop UNIQUE constraint from a MySQL table?
- How can we set PRIMARY KEY on multiple columns of an existing MySQL table?
- How can we put comments in a column of existing MySQL table?
- How can we create a table from an existing MySQL table in the database?
Advertisements