天天看點

count(0),count(1),count(*)總結與count(column)

總結select count(*)、count(1)、count(0)差別 效果:

三者的傳回結果是一樣的。

意義:

當count的參數是具體值時

如count(0)、count(1)、count('a')、count(100)

,count的參數已沒有實際意義了。

範圍:

在統計範圍,count(*)和count(1) 和count(0)一樣,都包括對NULL的統計(因為oracle僞列rowid不會為NULL);count(column) 是不包括NULL的統計。

速度:

相差不大,count(*),自動會優化指定到那一個字段。是以沒必要去count(1),用count(*),sql會幫你完成優化的

count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)
count(0),count(1),count(*)總結與count(column)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30126024/viewspace-1966440/,如需轉載,請注明出處,否則将追究法律責任。

轉載于:http://blog.itpub.net/30126024/viewspace-1966440/