【Oracle】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

posted @ 2019-12-31 15:28  逆火狂飙  阅读(181)  评论(0)    收藏  举报
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东