oracle exists and not exist
先看下面的例子:oracle中两个系统表.emp,dept.
example:
1:not exists(not in)
not exists:
这条语句返回select * from scott.dept d where e.deptno=d.deptno and d.deptno=10条件满足的结果集.也就是说,
返回的结果集中不存在d.deptno=10结果集的记录,即emp表中没有dept表中d.deptno=10的记录.
SQL> select empno,ename,deptno from scott.emp e where not exists(select * from scott.dept d where e.deptno=d.deptno and d.deptno=10);
EMPNO ENAME DEPTNO
----- ---------- ------
7369 SMITH 20
7499 ALLEN 30
7521 WARD 30
7566 JONES 20
7654 MARTIN 30
7698 BLAKE 30
7788 SCOTT 20
7844 TURNER 30
7876 ADAMS 20
7900 JAMES 30
7902 FORD 20
11 rows selected
not in:
第一个where条件必须给定字段(deptno), 第二个sql语句中,必须明确给定要查询的字段是哪个(deptno).
SQL> select empno,ename,deptno from scott.emp e where deptno not in(select deptno from scott.dept d where e.deptno=d.deptno and d.deptno=10);
EMPNO ENAME DEPTNO
----- ---------- ------
7369 SMITH 20
7499 ALLEN 30
7521 WARD 30
7566 JONES
相关文档:
oracle表空间操作详解
1
2
3作者: 来源: 更新日期:2006-01-04
5
6
7建立表空间
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
1、查找表的所有索引(包括索引名,类型,构成列):
select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and t.table_name = 要查询的表
2、查找表的主键(包括名称,构成列):
select cu.* from user_cons_columns cu, user_constr ......
Oracle 物件的命名限制
任何物件的名稱不得超過 30 位元(Bytes)
Oracle 的 dummy query 寫法
SELECT SYSDATE from dual
Oracle 選取部分資料的方法
SELECT * from table WHERE ROWNUM<10; /* 取出前 10 筆 */
實現 Oracle 上的分頁顯示 [精華] ......
在系统时间基础上延迟5秒
sysdate+(5/24/60/60)
在系统时间基础上延迟5分钟
sysdate+5/24/60
在系统时间基础上延迟5小时
sysdate+5/24
在系统时间基础上延迟5天
sysdate+5
在系统时间基础上延迟5月
add_months(sysdate,-5)
在系统时间基础上延迟5年
add_months ......
Oracle TNS简述
什么是TNS?
TNS是Oracle Net的一部分,专门用来管理和配置Oracle数据库和客户端连接的一个工具,在大多数情况下客户端和数据库要通讯,必须配置TNS,当然在少数情况下,不用配置TNS也可以连接Oracle数据库,比如通过JDBC.如果通过TNS连接Oracle,那么客户端必须安装Oracle client程序.
TNS有那些配置文件 ......