ORACLE 在WHERE子句中引用列别名的问题
SQL> select sal,comm from emp
2 where sal<2000;
SAL COMM
---------- ----------
800
1600 300
1250 500
1250 1400
1500 0
1100
950
1300
8 rows selected.
SQL> select sal as salary,comm as commission from emp
2 where salary<2000;
where salary<2000
*
ERROR at line 2:
ORA-00904: "SALARY": invalid identifier
SQL> select * from
2 (
3 select sal as salary,comm as commission from emp
4 ) x
5 where salary<2000;
SALARY COMMISSION
---------- ----------
800
1600 300
1250 500
1250 1400
1500 0
1100
950
1300
8 rows selected.
将取别名的查询作为内联视图,便可以在外部查询中引用其中的别名列。为什么要这么做呢?WHERE子句是在SELECT之前进行处理的,这样,在处理求解“问题”查询的WHERE子句之前,SALARY和COMMISSION并不存在,要到WHERE子句处理完成之后,别名才生效。然而,from子句是在WHERE之前处理的。将原查询放在from子句中,那么,在最外层的WHERE子句之前,以及最外层的WHERE子句“看到”别名之前,就已经生成了查询结果。
相关文档:
oracle表空间操作详解
1
2
3作者: 来源: 更新日期:2006-01-04
5
6
7建立表空间
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
declare
v_isexist number(3,0):=0;
begin
select count(1) into v_isexist from sys.all_objects where owner = 'TEST' and object_type = 'TABLE' and object_name = 'TAB1';
if v_isexist>0 ......
使用模糊查询:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
Date startdate = sdf.parse(start_date);
Date enddate = sdf.parse(end_date);
List list = sess.createCriteria(MyTabel.class)
.add( ......
DBA要定时对数据库的连接情况进行检查,看与数据库建立的会话数目是不是正常,如果建立了过多的连接,会消耗数据库的资源。同时,对一些“挂死”的连接,可能会需要DBA手工进行清理。
以下的SQL语句列出当前数据库建立的会话情况:
select sid,serial#,username,program,machine,status
from v$session;
......
http://www.cnblogs.com/ajian/archive/2009/08/25/1421063.html
TO_DATE格式(以时间:2007-11-02 13:45:25为例)
Year:
yy two digits 两位年 &nbs ......