What does “select count(1) from table_name” on any database tables mean?

前端 未结 9 591
被撕碎了的回忆
被撕碎了的回忆 2020-12-22 18:38

When we execute select count(*) from table_name it returns the number of rows.

What does count(1) do? What does 1 signify here

9条回答
  •  萌比男神i
    2020-12-22 19:13

    You can test like this:

    create table test1(
     id number,
     name varchar2(20)
    );
    
    insert into test1 values (1,'abc');
    insert into test1 values (1,'abc');
    
    select * from test1;
    select count(*) from test1;
    select count(1) from test1;
    select count(ALL 1) from test1;
    select count(DISTINCT 1) from test1;
    

提交回复
热议问题