易截截图软件、单文件、免安装、纯绿色、仅160KB

oracle中select 1和select *的区别

创建myt表并插入数据,如下:
create table myt(name varchar2,create_time date)
 insert into myt values('john',to_date(sysdate,'DD-MON-YY'));
 insert into myt values('tom',to_date(sysdate,'DD-MON-YY'));
 insert into myt values('lili',to_date(sysdate,'DD-MON-YY'));  
 在sql*plus中显示如下:
SQL> select * from myt;
 
NAME       CREATE_TIME
---------- -----------
john       2010-5-19
tom        2010-5-19
lili       2010-5-19
 
SQL> select 1 from myt;
 
         1
----------
         1
         1
         1
SQL> select 0 from myt;
 
         0
----------
         0
         0
         0
从以上结果 可以看到,select constant fromtable 对所有行返回对应的常量值(具体应用见下面),
而select * from table则返回所有行对应的所有列。
select 1常用在exists子句中,检测符合条件记录是否存在。
如select * from T1 where exists(select 1 from T2 where T1.a=T2.a) ;
T1数据量小而T2数据量非常大时,T1<<T2 时,1) 的查询效率高。
“select 1”这里的 “1”其实是无关紧要的,换成“*”也没问题,它只在乎括号里的数据能不能查找出来,是否存在这样的记录,如果存在where 条件成立。
如下示例:
SQL> select 1/0 from dual;
 
select 1/0 from dual
 
ORA-01476: 除数为 0
SQL> select * from myt where  exists(select 1/0 from dual);
 
NAME       CREATE_TIME
---------- -----------
john       2010-5-19
tom        2010-5-19
lili &nbs


相关文档:

ORACLE 的补丁下载地址 (转)

oracle补丁下载
关键字: oracle
9.2.0.4  = 3095277
9.2.0.5  = 3501955
9.2.0.6  = 3948480
9.2.0.7  = 4163445
9.2.0.8  = 4547809(9i最终)
10.1.0.3 = 3761843
10.1.0.4 = 4163362
10.1.0.5 = 4505133
10.2.0.2 = 4547817
10.2.0.3 = 5337014
10.2.0.4 = 6810189
下 ......

oracle keep(first/last)


 先看一段ORACLE官方文档
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/analysis.htm#25806:
FIRST/LAST Functions
The FIRST/LAST aggregate functions allow you to return the result of an aggregate applied over a set of rows that rank as the first or last with respect to a ......

Oracle中的To_date函数


Oracle中的to_date()函数
to_date()与24小时制表示法及mm分钟的显示:
一、在使用Oracle的to_date函数来做日期转换时,很多Java程序员也许会直接的采用“yyyy-MM-dd     HH:mm:ss”的格式作为格式进行转换,但是在Oracle中会引起错误:“ORA 01810 格式代码出现
  &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号