Oracle collection operations

Source: Internet
Author: User

Keywords:

1. UNION: UNION. All content is queried and displayed once again;

2. union all: UNION set. ALL content is displayed, including duplicate content;

3. INTERSECT: intersection. Only duplicate items are displayed;

4. MINUS: The difference set, which only shows that the other party does not have (it is related to the Order)

Example:

Create Table emp2 under scott, which only contains information about employees of 20 departments in emp:

Code: create table emp2 as select * from emp where deptno = 20;

Let's take a look at the differences between the emp and emp2 tables:

[Emp table structure and content]

 

[Emp2 table structure and content]

~ Verify UNION and UNION ALL

UNION: select * from emp UNION select * from emp2;/* use this statement. duplicate content is not displayed */

 

Union all: select * from emp union all select * from emp2;/* when this statement is used, repeated content is still displayed */

~ Verify INTERSECT

INTERSECT: select * from emp INTERSECT select * from emp2;/* use this statement to display only records that are repeated in two tables */


~ Verify MINUS

MINUS: select * from emp MINUS select * from emp2;/* use this statement to return the records showing the Differences */

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.