Invalid ale Data Processing and constraints, and invalid ale Data Processing

Source: Internet
Author: User

Invalid ale Data Processing and constraints, and invalid ale Data Processing
Other DML statements for data processing: Constraints

Constraint is a provision
** NOT NULL
UNIQUE
PRIMARY KEY
FOREIGN KEY
CHECK **
You can create constraints when creating tables.
After creating a table, you can modify the constraints.

You can define constraints at the table or column level.
You can view constraints through data dictionary
Table-level constraints and column-level constraints:

UNIQUE:
Unique constraint. Multiple NULL values are allowed: NULL.

Foreign key:
Foreign key: indicates the column in the child table at the table level.
REFERENCES: columns marked in the parent table
On delete cascade: When the columns in the parent table are deleted, the corresponding columns in the child table are also deleted.
On delete set null (cascade NULL): The corresponding columns in the subtable are empty.

CHECK:
It can be understood as a custom constraint.

Constraint addition and Deletion Query Constraints

In practice, I will write an article separately. The most difficult part of learning SQL is subquery, which requires more practice. Here I will tell you the Highly Efficient contact method, that is, pay attention to the writing format. For example:

-- Query the information of the Department with the lowest average salary and the average salary of the department SELECT d. *, (SELECT avg (salary) FROM employees WHERE department_id = d. department_id) FROM orders dWHERE department_id = (SELECT department_id FROM employees group by department_id HAVING avg (salary) = (SELECT min (avg (salary) FROM employees group by department_id ))

This writing format facilitates analysis

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.