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
Why sql query is slow?
What is pl sql and why it is used for?
What is sql query limit?
what is error ora-03113: end-of-file on communication channel?
what is msql? : Sql dba
what are the advantages and disadvantages of cascading style sheets? : Sql dba
Is vs as in pl sql?
what are set operators in sql? : Sql dba
what are string data types? : Sql dba
how to create a test table in your mysql server? : Sql dba
What is the use of count (*) in sql?
Define SQL and state the differences between SQL and other conventional programming Languages?
What is data control language (dcl)?
Why is sharding used?
How to check if a column is nullable before setting to nullable?