Cascade, no action, Restrict, set null in Mysql

Source: Internet
Author: User

The meanings of the Cascade, no action, Restrict, and set null foreign key constraints in Mysql to the sub-table: If NO candidate key is found in the parent table, the description of the parent table of the insert/update foreign key constraint on the child table is not allowed: when updating or deleting a parent table to update or delete one or more candidate keys that match the row in the child table, the behavior of the parent table depends on: when defining the Foreign keys of a sub-table, The on update/on delete clause is specified. InnoDB supports five methods: When the cascade method is used to update/delete records on the parent table, synchronize update/delete matching records of sub-tables. On delete cascade is available from mysql3.23.50. on update cascade starts from mysql4.0.8 and can be used to update/delete records in the parent table in the set null mode, set the columns of matched records in the child table to null. 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 from mysql4.0.8 start available No action mode if the child table has matched records, then the parent table corresponding to the candidate key update/delete operation is not allowed this is ANSI SQL-92 standard, the Restrict mode and no action are supported from mysql4.0.8, and foreign key constraints are checked immediately.

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.