SQL collection (notes)

Source: Internet
Author: User

SQL collection (notes)

SQL is about the set

Oracle is a relational data, where data tables are a set of regular data. Therefore, when using SQL statements, it will save a lot of efficiency if you can follow the set idea, it also makes the statement clearer.

1. Four set Operators

1) union returns non-repeated data rows;

2) union all returns all data rows (including duplicate rows );

3) minus returns the data rows that exist in the first input query and do not exist in other queries;

4) intersect returns the data rows that exist in all data queries.

Note: Except for union all, all set operations require sorting results/unique value operations, which means more efficiency is required. Therefore, if you do not care about repetition, try to use union all.

2. null)

The relational model only has two results: True, false, and unknown. The SQL language allows three results: True, false, and unknown.

Oracle considers the unknown results to be correct, so you must pay attention to this in many search conditions. Otherwise, the search results may differ greatly from the expected ones.

By default, the order by statement puts the null value in the final output. If you want to put it in the front side, you need to add nulls first after the order by statement.

Null is automatically removed from the aggregate function, that is, it is not involved in the operation of the aggregate function.

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.