What is different between union and minus?

Answer Posted / rahul gaikwad

Let's consider the difference between Minus and Union using
following examples.

1.create TABLE A AND B With similar structure
2.insert records in Table A and B.
3.Keep some records identical(here 2 rows).
4.find out the difference betwn 2 looking into the output.


CREATE TABLE A(NAME VARCHAR2(30));
INSERT INTO A VALUES('A');
INSERT INTO A VALUES('B');
INSERT INTO A VALUES('C');
INSERT INTO A VALUES('D');
COMMIT;

CREATE TABLE B(NAME VARCHAR2(30));
INSERT INTO b VALUES('A')
INSERT INTO b VALUES('B')
INSERT INTO b VALUES('Y')
INSERT INTO b VALUES('X')
COMMIT;



1) SELECT * FROM A
MINUS
SELECT * FROM B

NAME
------------------------------
C
D
2 rows selected



2)SELECT * FROM A
UNION
SELECT * FROM B


NAME
------------------------------
A
B
C
D
Y
x
6 rows selected

Is This Answer Correct ?    28 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to fix oracle error ora-00942: table or view does not exist

656


How does stored procedure reduce network traffic?

629


Determine if oracle date is on a weekend?

653


GLOBAL TEMPORARY TABLE over Views in advantages insolving mutating error?

2671


Why are indexes and views important to an organization?

602






Is it possible to sort a column using a column alias?

693


How do I find duplicates in sql?

602


Is nosql relational?

625


Can we use insert statement in function?

617


Are stored procedures faster than dynamic sql?

627


How consistent is the view of the data between and within multiple sessions, transactions or statements ?

1804


What kind of join is join?

631


What is having clause in sql?

630


What is sql keyword?

657


What is informix sql?

613