您的位置:首页 > 数据库 > Oracle

oracle中的select 1 from 表名的含义~

2013-03-05 15:29 501 查看
1、select 1 from table 与 select anycol(table中的任意一行) from table 与 select * from table 作用上没有差别,都是查询是否有记录。select 1 from table 中的“1”是一个常量,所以查询出来的所以行都是它,但从效率上来说:1 > anycol >*,因为不用查字典表。
2、查看记录条数可以用select sum(1) from table; 等价于 select sum(*) from table;
3、(1)select 1 from table  增加临时列,每行的列值是写在select后的数,这条sql语句中是1
(2)select count(1) from table  不管count(a)的a值如何变化,得出的值总是table表的行数
(3)select sum(1) from table  计算临时列的和。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: