Home > Daily Programming > Mysql Knowledge > How to delete foreign keys in Mysql? (Pictures + Videos)

How to delete foreign keys in Mysql? (Pictures + Videos)

藏色散人
Release: 2018-10-25 15:16:59
Original
22419 people have browsed it

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

How to delete foreign keys in Mysql? (Pictures + Videos)

The syntax for deleting foreign keys is as follows:

alter table +表名 + drop foreign key +外键名字
Copy after login

The command example for deleting foreign keys is as follows:

alter table stu drop foreign key stu_class;
Copy after login

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.

How to delete foreign keys in Mysql? (Pictures + Videos)

#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.

How to delete foreign keys in Mysql? (Pictures + Videos)

Then use Navicat to delete the foreign key.

How to delete foreign keys in Mysql? (Pictures + Videos)

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template