Problem of intersection difference set of two tables in Oracle __oracle

Source: Internet
Author: User

1, intersect operation
Return the same part of the query result both their intersection

Sql> SELECT * FROM ABC
2 intersect
3 SELECT * from ABC2;

2, minus operation
Returns the portion of a row that is not the same as the second query result in the first query result.
Is the difference set of two results

Sql> SELECT * from ABC2
2 minus
3 SELECT * FROM ABC;

3, Union-union all
(1) The Union filters out duplicate records after the table is connected, so the resulting set is sorted after the table is connected, the duplicate records are deleted, and the results are returned.
(2) UNION all simply merges the two results and returns. If there are duplicate data in the two result sets returned, the result set returned contains duplicate data

Note: In terms of efficiency, union All is much faster than union, and if you can confirm that the merged two result sets do not contain duplicate data, use UNION ALL

There are two basic rules for the result set of queries with UNION combinations:

(1) The number of columns in all queries must be the same as the order of the columns.

(2) Data types must be compatible

Union:
Sql> Select D.code,d.name from ABC D
2 Union
3 Select E.code,e.name from ABC3 e;

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.