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

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、查找表的所有索引(包括索引名,类型,构成列):
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 存储过程实例


/*不带任何参数存储过程(输出系统日期)*/
create or replace procedure output_date is
begin
dbms_output.put_line(sysdate);
end output_date;
/*带参数in和out的存储过程*/
create or replace procedure get_username(v_id in number,v_username out varchar2)
as
begin
  select username into v_usern ......

Oracle 创建不同数据块的表空间

       Oracle数据库的数据块DB_BLOCK_SIZE大小确定数据库的最小数据块的大小,在创建表空间时可以如果不想使用默认的数据块大小,可以通过设置自己的数据块大小。
    具体实例如下:
   create tablespace test_16k
      bloc ......

LINUX下Oracle库备份脚本

vi /opt/back.sh(oracle用户)
#!/bin/ksh
tim=`date +%Y%m%d`
unset USERNAME
#export DISPLAY=0.0.0.0:0.0
#export ORACLE_BASE=/home/oraprod3
#export ORACLE_HOME=/prod/oracle/prod3db/9.2.0
#export ORACLE_SID=PROD3_db
#export LD_LIBRARY_PATH=/prod/oracle/prod3db/9.2.0/lib
#export ORACLE_TERM=vt100 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号