sqlserver 关于count(1),count(*)测试
今天做了一个简单的测试工作
create table test1(col1 int identity(1,1),col2 char(5))
go
insert into test1(col2) select '12345'
go 1000
---插入1000条col2 not null 的数据
insert into test1(col2) select null
go 100
-----插入100条col2 null 的数据
--------test-------------------
select count(1) from test
-----1100
select count(2) from test
-----1100
select count(*) from test
-----1100
select count(col2) from test
-----1000
----------总结----------
(1)count(1),count(*) 速度一样
(2)count 函数统计非 null的行数总和
浙公网安备 33010602011771号