This article mainly introduces how to delete foreign keys in mysql.
So in the previous article, I have introduced you to the basic knowledge about mysql foreign keys, including the basic definition and usage of foreign keys.
Before starting to introduce the content of this section, you can choose to refer to the following articles:
[What is Mysql foreign key? What are the uses? 】
【How to create a foreign key in mysql database? 】
【How to use mysql foreign keys? Introduction to the use of foreign keys in Mysql database】
【How to add foreign keys to the Mysql data table? 】
Let’s continue to use simple examples to introduce the method of deleting foreign keys in MySQL.
1. Use the command line tool to delete foreign keys
The syntax for deleting foreign keys is as follows:
alter table +表名 + drop foreign key +外键名字
The command example for deleting foreign keys is as follows:
alter table stu drop foreign key stu_class;
Here we are deleting the foreign keys in the stu table.
Note: Multiple foreign keys can exist in a data table.
Then we can check whether the foreign key is successfully deleted through the Navicat tool.
#As shown in the figure, we can find that there is no foreign key in the stu table. Indicates that we have successfully deleted the foreign key.
2. Delete foreign keys through Navicat
Navicat is a set of fast, reliable and quite cheap database management tools, designed to simplify database management and reduce system costs. Management costs, and built with an intuitive graphical user interface, let you create, organize, access and share information securely and easily.
First we can add a foreign key field c_id to the stu table.
Then use Navicat to delete the foreign key.
As shown in the picture, we can click the Delete Foreign Key button.
This article is about the method of mysql deleting foreign keys. It is also very simple and easy to understand. I hope it will be helpful to friends in need!
If you want to know more about mysql, you can follow the PHP Chinese website mysql video tutorial, everyone is welcome to refer to and learn!
The above is the detailed content of How to delete foreign keys in Mysql? (Pictures + Videos). For more information, please follow other related articles on the PHP Chinese website!