Constraints on building tables

Source: Internet
Author: User

1. Non-null constraints

The ① field cannot be null

②null not equal to ""; Oracle does not allow "" to be written to a non-empty string field

2. Unique constraints

① specifies that data for one or more columns is unique

② A table can have multiple unique constraints

③unique

3. PRIMARY KEY constraints

① to specify a column or columns of the primary key for multiple columns

② primary key columns must have both a non-null constraint and a UNIQUE constraint

③ A table can have only one PRIMARY KEY constraint

④ the role of the PRIMARY KEY constraint: The PRIMARY KEY constraint is able to determine a unique row of data, automatically generate indexes according to the primary key column, improve the efficiency of data retrieval, ensure the uniqueness and standardization of data

How to ⑤ PRIMARY KEY constraints:

A. Unique Code fields

B. Auto-growing integer value field: Oracle is implemented by ordinal column; Other databases have fields that support self-growing types; suitable for single databases; not for distributed databases

C. GUI D globally uniquely identifies: 32-bit-length 16-in-one string; Suitable for distributed database

4. Check constraints

By checking the rule statement: the size of a qualified value; A list of qualified values

5. FOREIGN KEY constraints

Constraint relationships between two tables

Constraints on building tables

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.