Data Integrity Summary

Source: Internet
Author: User

The integrity of the data is achieved through various constraints;

PRIMARY KEY constraint: (a table can have only one PRIMARY KEY constraint)

The primary key is each row that identifies the table, which is a constraint applied to the column.

The primary key comes with non-nullability and uniqueness.

It is defined in the following way:

CREATE TABLE Students (
ID INT PRIMARY KEY);

Unique constraint:

It means that all values for a given column must be unique, and the value of each row in the table must be unique.

The unique constraint is consistent with the functionality of the primary KEY constraint in addition to allowing null values and allowing multiple unique constraints in a table.

Keyword: UNIQUE

For example, the value of the Tel column can only be achieved with the following statement:

CREATE TABLE Students (
TEL VARCHAR (a) UNIQUE);

CHECK constraints:

When you ask for input data in a certain range of time can be used to check the constraints;

For example, the age required for input is between 15-20 years old and can be achieved with the following sentences;

CREATE TABLE Students (
Age Int. CHECK (age between and 20));

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.