失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > select count(*) from temp 与select count(1) from temp有什么区别

select count(*) from temp 与select count(1) from temp有什么区别

时间:2021-08-02 22:44:58

相关推荐

select count(*) from temp 与select count(1) from temp有什么区别

select count(*) from temp 与select count(1) from temp有什么区别

----count(*)是整个表中有多少条记录,扫描的是整个表 ----

----count(1)是第一列有多少个值,扫描的是一列 ----

第一句是对的.第二句就错了.count(1)并不是针对第一列,你可以试试count('A')

同样是可以得到整个表的记录数的.这里只是用一个实际值罢了.当然也可以是一个字符串.count('Aasd')都是可以的.

这种采用实际值的例子比用*都要快.因为它执行的时候不是扫描整个表

如果觉得《select count(*) from temp 与select count(1) from temp有什么区别》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。