DB2 foreign key

Source: Internet
Author: User
Tags db2 db2 foreign key

DB2's foreign key has four settings on Delete:

No action: do not be affected by the literal meaning. It actually means the same as restrict Delete.
Restrict Delete: indicates that when deleting a parent table record, if the associated records of the child table exist, the table will be rolled back and an error is returned;
Cascade: indicates that the records of the sub-table are deleted (cascade deletion.) while the parent table is deleted .);
Set NULL: when the parent table is deleted, the foreign key column of the child table is set to NULL;

 

The difference between no action and restrict Delete is that:

Note:No actionIs the default situation for DB2 UDB on Unix or windows. Restrict Delete is the default situation for DB2 UDB on Z/OS.

No action means 'do not perform any operation '. When some people are confused, they do not think of a key role of foreign keys: Prevent data islands from being wrong.

Therefore, the true meaning of "no action" is "do not perform any operation, and the DB processes the operation according to the original logic '. The original logic of DB isRestrict Delete.

--- Correct your understanding of errors.

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.