marc by marc jacobs official website mysql creates foreign keys

WBOY
Release: 2016-07-29 08:35:14
Original
905 people have browsed it

Prerequisite for establishing a foreign key: The columns of this table must be of the same type as the foreign key (the foreign key must be the primary key of the table).
Function of foreign keys: To associate two tables, foreign keys can only refer to the values ​​of columns in the table!
Specify the primary key keyword: foreign key (column name)
Quote the foreign key keyword: references (foreign key column name)
Event triggering restrictions: on delete and on update, the parameter cascade( can be set Follow foreign key changes), restrict (restrict foreign key changes in the table), set Null (set null value), set Default (set default value), [default] no action
For example:
outTable table primary key id type int
Create Table with foreign keys:
create table temp(
id int,
name char(20),
foreign key(id) references outTable(id) on delete cascade on update cascade);
Instructions: Set the id column as external The key refers to the id column of the outer table outTable. When the value of the foreign key is deleted, the corresponding column in this table is filtered. When the value of the foreign key changes, the corresponding column value in this table changes.

The above introduces the creation of foreign keys in mysql by marc by marc jacobs official website, including the content of marc by marc jacobs official website. I hope it will be helpful to friends who are interested in PHP tutorials.

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