count(1) and count(*) give the same result - both count null values - a
count on a specific column does not count null values - see example below
The result set is the same, but the performance may differ.
SQL> desc x
Name Null? Type
----------------------------------------- --------
----------------------------
N NUMBER
V VARCHAR2(5)
SQL> select * from x;
N V
---------- -----
1 a
2
c
SQL> select count(1) from x;
COUNT(1)
----------
3
SQL> select count(*) from x;
COUNT(*)
----------
3
SQL> select count(n) from x;
COUNT(N)
----------
2
SQL> select count(v) from x;
COUNT(V)
----------
2
|---------+--------------------------------------------------------->
| | "Edwin Uy " |
| | <oracledba-ezmlmshield-x93770188.[Email Address Removed] | azydba.com> |
| | |
| | 06/02/2004 07:05 AM |
| | |
|---------+--------------------------------------------------------->
>----------------------------------------------------------------------------------------------|
| |
| To: "LazyDBA.com Discussion" <> |
| cc: |
| Subject: Just out of curiosity |
>----------------------------------------------------------------------------------------------|
Hi all,
select count(*) or select count(1) . does it really matter . ???
Cheers,
EDWIN ONG UY
\\|//
(o o)
^"^"^"^"^"^oOOo"^(_)^"oOOo^"^"^"^"^"^"^"^"^"^"^
"Choose a job you love, and you will never have to work a day in your
life." --Confucius
"How do I work? I grope." -- Albert Einstein
"Experience is the best teacher, enrolling in the class is the biggest
problem." -- Anonymous
--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: send a blank email to oracledba-[Email address protected]
By using this list you agree to these terms:
http://www.lazydba.com/legal.html
Oracle LazyDBA home page