Set Operators in DBMS.
Set Operator : These set operator are used to combine results of two or more query and it has following three format:
- Union, Intersect
- Union all, Intersect all
- Union Corresponding, intersection Corresponding
In the first two format the following condition must satisfy:
- No of columns in first query must be same as to number of columns in seconds query and so on .
- Domain of its first column in first query must be same to domain of the first column in second query and so on.
In third format the first condition is relaxed.
The syntax is given as follow:
QUERY1
UNION [ALL] [CORRESPONDING] / INTERSECT [ALL] [CORRESPONDING]
QUERY2; ([]=Optional)
where QUERY1 and QUERY2 are queries of any complexity.
Meaning of following:
A={a,b,c}
B={b,c,d}
A U B={a,b,c,d}
A ⋂ B={b,c}
Union : In case of union , output will consists of the rows which are common in all outputs of queries without repeating along with rows which are not common.
Intersect : In case of intersect, output will consists of the rows which are common in all output of query without any repetition.
Union all, Intersect all :
A U all B={a,b,c,b,c,d}
A ⋂ all B={b,b,c,c}
In case of all along with Union and Intersect output remains same that of Union and Intersect but case of all output will have the repeated rows also.
Union Corresponding / Intersection Corresponding:
when corresponding is taken then the condition of number of columns in query is relaxed and query evaluating engine will do matching of column and if matching column are found then Union and Intersect is apply.
Comments
Post a Comment