Home  >  Article  >  Database  >  How to create constraints in phpmyadmin

How to create constraints in phpmyadmin

藏色散人
藏色散人Original
2020-04-06 10:37:513472browse

How to create constraints in phpmyadmin

phpmyadminHow to create constraints? How to use phpmyadmin to establish foreign key constraints

In the past, sql statements were used to associate primary and foreign keys. Now it is much more convenient to use visual phpmyadmin, but when doing primary and foreign key constraints, it is I can't find where the operation is. Searches on the Internet are also full of strange things, all of which are very obscure. Many of them say that you need to use the insert sql statement. In fact, you don’t need to. See the steps:

I created two tables:

Table 1: class1 (main table)

How to create constraints in phpmyadmin

## Table 2: class2: (attached table)

How to create constraints in phpmyadmin

At this time, I hope that the name in class1 is associated with the data_name in class2. At this time, we need to pay attention to several points:

First: The main table can have multiple foreign keys. Foreign keys The primary key of the main table can be repeated, but the foreign key must be the primary key of the attached table, and the type must be the same

Second: The types of the two tables must be InnoDB engines. This can be done when creating the table Set it up when:

How to create constraints in phpmyadmin

Of course, it doesn’t matter even if we create the table, we can still set it up:

How to create constraints in phpmyadmin

At this time, you can see a related view in the table, which may be related to the version. Some of them will be in

How to create constraints in phpmyadmin

Relationship view appears here;

Click:

How to create constraints in phpmyadmin

Perfect

The above is the detailed content of How to create constraints in phpmyadmin. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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