Foreign keys are only allowed with InnoDB

Source: Internet
Author: User

1. Only the InnoDB engine allows the use of foreign keys, so our datasheets must use the InnoDB engine.

2. Note:
1, must use the InnoDB engine;
2, foreign keys must be indexed (index);
3, foreign key binding relationship use "on DELETE CASCADE" here, meaning that if the foreign key corresponding data is deleted, the associated data is completely deleted,

3. The update operation is similar, because we have already defined the foreign key Delete, the update operation is cascade when the table is built earlier, so we can test the data directly here.

4. Use foreign keys to make simultaneous deletions and updates to multiple associated tables, thus ensuring consistency of data.

. Cascade Way
Synchronize update/delete out a matching record of a child table when Update/delete records on the parent table
On DELETE cascade available from mysql3.23.50; On UPDATE cascade available starting from mysql4.0.8

. Set NULL mode
Set the column of the matching record on the child table to NULL when the record is update/delete on the parent table
Note that the foreign key column of the child table cannot be not NULL
On delete Set NULL is available from mysql3.23.50; On update set NULL is available starting from mysql4.0.8

. No Action Mode
If there are matching records in the child table, the Update/delete action is not allowed for the parent table corresponding to the candidate key
This is the ANSI SQL-92 standard, starting from mysql4.0.8 support

. Restrict Way
Same no action, check foreign KEY constraints immediately

. Set default mode
The parser recognizes this action, but InnoDB does not recognize it and does not know what it means ...

Foreign keys are only allowed with InnoDB

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.