-1

What is difference between select count(1) from table ; and select count(*) from table ;

Here my table contain 5rows and 5column

3

Nothing. count(1) is implicitly transformed into count(*). See below:

SQL> select tracefile from v$process where addr = (select paddr from v$session where sid = sys_context('userenv', 'sid'));

TRACEFILE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/orcl_o71/ORCL/trace/ORCL_ora_3610.trc

SQL> alter session set events '10053 level 1';

Session altered.

SQL> select count(1) from dual;

  COUNT(1)
----------
         1

SQL> alter session set events '10053 off';

Session altered.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.4.0.0.0
[oracle@o71 ~]$ grep "Final query" -A 1 /u01/app/oracle/diag/rdbms/orcl_o71/ORCL/trace/ORCL_ora_3610.trc
Final query after transformations:******* UNPARSED QUERY IS *******
SELECT COUNT(*) "COUNT(1)" FROM "SYS"."DUAL" "DUAL"
[oracle@o71 ~]$

Not the answer you're looking for? Browse other questions tagged or ask your own question.