Today I am going to describe the Difference Between Union And Union All in Oracle Database.
The Union is an Operator that is used to combine two or more select statement data into a single unit or display a single result. Union removes duplicate data from the result set while Union All is also an Operator that is used to combine two or more select statement data into a single unit or display a single result. Union All do not remove duplicate data from the result set.
Let's Start Today Topic.
What is the Union Operator in Oracle Database?
What is the Union All Operator in Oracle Database?
Basic Difference between Union and Union All in Oracle Database
What is the Union Operator in Oracle Database?
The Union is an Operator that is used to combine two or more select statement data into a single unit or display a single result.
Union removes duplicate data from the result set.
Example of Union Operator in Oracle Database
SELECT EMPNO, ENAME FROM EMP
UNION
SELECT DEPTNO, DNAME FROM DEPT
What is Union All Operator in Oracle Database?
Union All is also an Operator that is used to combine two or more select statement data into a single unit or display a single result.
Union All do not remove duplicate data from the result set. Union All displays all data from both tables.
Example of Union All Operator in Oracle Database
select empno,ename from emp
union all
select 1,dname from dept
Basic Difference between Union and Union All in Oracle Database
- Union removes duplicate data from the result set.
- Union All do not remove duplicate data from the result set.
- Union All is retrieved fast data while the union is retrieved slow data.
select ename from emp
union all
select deptno from dept;
it will give an error because the data type are not same
select empno,ename from emp
union all
select dname from dept;
it will give an error because the number of columns are not same
Thanks and share
najeebalikhel@gmail.com
youtube Channel: Najeeb Alikhel

Comments
Post a Comment