您的位置:首页 > 数据库

sqlserver 关于count(1),count(*)测试

2015-07-29 19:35 260 查看
今天做了一个简单的测试工作

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的行数总和
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: