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

What are hotfixes and patches?

700


Is there a pl/sql pragma similar to deterministic, but for the scope of one single sql select?

776


What is function and procedure in pl sql?

717


What is vector point function?

782


Explain the difference between triggers and constraints?

723


Which nosql database is best?

689


what are myisam tables? : Sql dba

734


What is the difference between jpql and sql?

805


What are commit, rollback, and savepoint?

748


How long it takes to learn pl sql?

731


how to check myisam tables for errors? : Sql dba

910


How do you update a table in sql?

695


How do you delete duplicates in sql query using rowid?

729


What is autocommit sql?

726


Can we enter data in a table in design view?

730