Friday 18 February 2011

UNION and UNION ALL in oracle

Difference between union and union all?

1. UNION only selects distinct values and UNION all selects all values.
2. UNION filters duplicates values and UNION ALL does not.

Simple example to test it:

create table foo(
foo_id number,
foo_name varchar2(30)
);

insert into foo values(1,'FAWAD');
insert into foo values(1,'NAZIR');

select * from foo
union
select * from foo;

select * from foo
union all
select * from foo;

No comments:

Post a Comment

Azure OpenAI Architecture Patterns & Deployment Patterns

Sharing some useful links that will help customers architect Azure OpenAI solution using the best practices: (1) Azure OpenAI Landing Zone r...