Integrity constraints (chapter summary)

Source: Internet
Author: User
1. The Integrity Constraint of the database is a check measure for data updating. One or more constraints exist on a data table. 2. There are five types of constraints: NOTNULL, UNIQUE, PRIMARYKEY, CHECK, and FOREIGNKEY ). 3. Define the constraints

1. The Integrity Constraint of the database is a check measure for data updating. One or more constraints exist on a data table. 2. constraints are divided into five types: non-NULL constraint (not null), UNIQUE constraint (UNIQUE), primary key constraint (primary key), CHECK constraint (CHECK ), foreign key constraint (foreign key ). 3. Define the constraints

1. The Integrity Constraint of the database is a check measure for data updating. One or more constraints exist on a data table.

2. constraints are divided into five types: non-NULL constraint (not null), UNIQUE constraint (UNIQUE), primary key constraint (primary key), CHECK constraint (CHECK ), foreign key constraint (foreign key ).

3. When defining constraints, you can use the CONSTRAINT keyword to set the CONSTRAINT name.

4. When setting foreign key constraints, you can perform cascade data update operations as follows.
On delete cascade: when the primary table data is deleted, the corresponding sub-table data is also deleted;
On delete set null: when the primary table data is deleted, the corresponding sub-table data is SET to null.

5. constraints can be set when the table is defined, or you can add constraints separately for existing data tables. The ALTER command is used to modify the constraints.

6. When a constraint is temporarily not in use, you can set it to disabled and then re-enable it.

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.