Count(*) 与 count(field) 一样吗?

有这么个表:

执行 

select count(*) from hy_test

select count(deptno) from hy_test

都得到 5

但执行

select count(name) from hy_test

却得到 

原来count(字段)是取 字段中不为空的记录数,所以name=null的三条被忽略了。

附:建表语句

CREATE TABLE hy_test
(
    deptno NUMBER(8,0) not null primary key,
    name NVARCHAR2(60)
)

插值语句:

insert into hy_test(deptno,name) values('1','Hr');
insert into hy_test(deptno,name) values('2','Dev');
insert into hy_test(deptno) values('3');
insert into hy_test(deptno) values('4');
insert into hy_test(deptno) values('5');

--END-- 2019-12-31 16:27

原文地址:https://www.cnblogs.com/heyang78/p/12124679.html