Marc by Marc Jacobs website MySQL create foreign key

Source: Internet
Author: User
Tags mysql create
The precondition for establishing a foreign key is that the column of this table must be the same as the foreign key type (the foreign key must be the outer primary key).
Foreign key effect: make two tables to form an association, foreign key can only reference the value of the column in the outside!
Specify PRIMARY KEY keyword: foreign key (column name)
Reference FOREIGN KEY keyword: references <外键表名> (foreign key column name)
Event Trigger limit: On delete and on UPDATE, set parameter cascade (following foreign key changes), restrict (Restrict foreign key changes in appearance), SET null (null value), set default, [Default]no action]
For example:
Outtable table primary key ID type int
To create a table that contains a foreign key:
CREATE TABLE Temp (
ID int,
Name Char (20),
FOREIGN key (ID) references outtable (ID) on the DELETE cascade on UPDATE cascade);
Description: Set the ID column to foreign key reference the ID column of the outer outtable when the value of the foreign key is removed from the corresponding column in this table except when the value of the foreign key changes the corresponding column value in this table.

The above describes the Marc by Marc Jacobs website MySQL established foreign key, including the Marc by Marc Jacobs website content, I hope the PHP tutorial interested friends helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.