Select COUNT(*) and COUNT(column) are different things!
来源:互联网 发布:淘宝如何设置花呗支付 编辑:程序博客网 时间:2024/06/18 14:38
Select COUNT(*) and COUNT(column) are different things!
Every now and then I see someone wondering why Oracle is “returning wrong results” for some count queries when counting using COUNT(column_name) instead of COUNT(*) or COUNT(<constant>).
Oracle is actually returning correct results, its just that sometimes the people asking the questions haven’t realized that COUNT(column) is something semantically different from COUNT(*).
COUNT(*) operation countsall rows fed to it by execution plan branch under it.
COUNT(*) operation统计表对应的段中所有的数据行(包括其上各列的值为空值null的数据行)
COUNT(column) operation on the other handcountsall non-null values in that column from rows fed to it by execution plan branch under it.
COUNT(column) operation统计表对应的段中其列上的值不为空值null的数据行。
And here’s a little example:
SQL> select count(*) from v$session; COUNT(*)---------- 23SQL> select count(username) from v$session;COUNT(USERNAME)--------------- 1 <<-- only one non-null value in that columnSQL> select count(nvl(username,'blah')) from v$session; <<-- lets replace NULLs with non-nullsCOUNT(NVL(USERNAME,'BLAH'))--------------------------- 23参考:oracle count 0 谷歌
- Select COUNT(*) and COUNT(column) are different things!
- Count (*),Select Count(1),Select Count(column)的区别
- SQL Server DBCC & Count (*) Count(1) ,Select Count(column)
- select count (*)、count(1)、count(column)的区别
- Select Count (*)和Select Count(1)以及Select Count(column)区别
- Select Count (*)和Select Count(1)以及Select Count(column)区别
- Select Count (*)和Select Count(1)以及Select Count(column)的区别
- SELECT COUNT
- select count(*)
- count(*),count(1),count(column)性能比较
- count(*) count(1) count(column)的区别
- 关于count(*),count(1),count(column)
- count(*)、count(1)、count(column)的区别
- count(column) 和 count(*)和count(1)
- select count(*) ,count() , select *
- count(1) and count(*)
- 11i and R12 Table Count in Different Module
- select count(*) 和select count(1)和select count(col)
- 消息调度中心的学习资料汇总
- erlang snmp初学(2)
- 什么是统计信息以及收集查看方法
- 【原型设计】手机应用加载过程中常见的几个错误
- SAX、DOM、PULL的比较
- Select COUNT(*) and COUNT(column) are different things!
- Libsvm和Liblinear的使用经验谈<转>
- 孤儿进程与僵尸进程
- Chrome 和 Firefox下获取图片大小和尺寸
- U-Boot下的I2C设备的读写
- C语言指针
- Redis 在新浪微博中的应用
- redis监控软件---RedisLive
- LVS+Keepalived搭建服务器集群