What is different between union and minus?
Answer Posted / elumalai d
UNOIN:- It returns all the records from both tables without duplicates.
Example:-
A={1,2,3,4}
B={2,3,4,5,6}
AUB={1,2,3,4,5,6}
CREATE TABLE question36 (empid NUMBER);
CREATE TABLE quest36 (empid NUMBER);
INSERT INTO question36 VALUES(1);
INSERT INTO question36 VALUES(2);
INSERT INTO question36 VALUES(3);
INSERT INTO question36 VALUES(4);
INSERT INTO quest36 VALUES(2);
INSERT INTO quest36 VALUES(3);
INSERT INTO quest36 VALUES(4);
INSERT INTO quest36 VALUES(5);
INSERT INTO quest36 VALUES(6);
COMMIT;
SELECT empid FROM question36
UNION
SELECT empid FROM quest36;
EMPID
---------
1
2
3
4
5
6
DELETE FROM question36;
DELETE FROM quest36;
COMMIT;
MINUS:- It returns table A values not available in table B.
Example:-
A={1,2,3,4}
B= {2,3,5}
A-B={1,4}
INSERT INTO question36 VALUES(1);
INSERT INTO question36 VALUES(2);
INSERT INTO question36 VALUES(3);
INSERT INTO question36 VALUES(4);
INSERT INTO quest36 VALUES(2);
INSERT INTO quest36 VALUES(3);
INSERT INTO quest36 VALUES(5);
COMMIT;
SELECT empid FROM question36
MINUS
SELECT empid FROM quest36;
EMPID
---------
1
4
DROP TABLE question36;
DROP TABLE quest36;
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why is sharding used?
how to delete duplicate rows from a join tables(I have three tables on that join) how do you know which join is need to be used? The select statement I have is: SELECT gc_skill_type.skill_type, gc_area_tec.area, gc_technology.technology, gc_technology.id_technology, gc_area_tec.id_area_tec FROM gc_skill_type, gc_area_tec, gc_technology WHERE gc_area_tec.id_skill_type (+) = gc_skill_type.id_skill_type AND gc_technology.id_area_tec (+) = gc_area_tec.id_area_tec order by gc_skill_type.skill_type asc, gc_area_tec.area asc, gc_technology.technology asc
Explain aggregate functions are available there in sql?
What is lexical units in pl sql?
What is dense_rank?
Why cannot I use bind variables in ddl/scl statements in dynamic sql?
What is a primary key sql?
What is integrity in sql?
What is the difference between alter trigger and drop trigger statements?
Which data type is a composite type?
What is a boolean in sql?
Is it possible to create startup or shutdown trigger for on-schema?
what are all types of user defined functions? : Sql dba
which types of join is used in sql widely? : Sql dba
What are expressions?