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

oracle 笔记 II 之DML:数据操作语言

 DML:Data Manipulation Language 数据操作语言
包括:CRUD
1. insert语句
(1) 从其它表中复制数据,实现方法:在insert 语句中加入查询语句
insert into sales_reps(id,name,salary,commission_pct)  select employee_id,last_name,salary,commission_pct
from employees where job_id like '%rep';
(2) update中使用子查询
 update employees set job_id =  (select job_id from employees where employee_id = 205),
                               salary =  (select salary from employees where employee_id = 205)
           where employee_id = 114;
   如:更新114号员工的工作和工资使其与205号员工相同
   update employees set job_id =  (select job_id from employees where employee_id = 205),
      salary = (select salary from employees where employee_id = 205)
      where employee_id = 114
   再看一个问题,仔细体会解决步骤:
    更改 108 员工的信息: 使其 工资变为所在部门中的最高工资,job变为公司中平均工资最低的job
     分析:
 第1 步 首先查询 108 所在部门的最高工资是多少
    select max(salary) from employees where department_id =
  ( select department_id from employees where employee_id = 108)
 第 2 步 查询公司中平均工资最低的 job_id
     select job_id from employees group by job_id having avg(salary) =
     (select min(avg_sal) from(select avg(salary) avg_sal from employees  group by job_id) )
 第 3 步 实现更新
          update employees set salary = (  select max(salary) from employees 
             where department_id =


相关文档:

Oracle JOB 用法小结

一、设置初始化参数 job_queue_processes
  sql> alter system set job_queue_processes=n;(n>0)
  job_queue_processes最大值为1000
  
  查看job queue 后台进程
  sql>select name,description from v$bgprocess;
  
  二,dbms_job package 用法介绍
  包含以下子过程:
  
  ......

ORACLE CASE函数

Case具有两种格式。简单Case函数和Case搜索函数。
 
--简单Case函数
CASE sex
WHEN '1' THEN '男'
WHEN '2' THEN '女'
ELSE '其他' END
--Case搜索函数
CASE WHEN sex = '1' THEN '男'
WHEN sex = '2' THEN '女'
ELSE '其他' END
这两种方式,可以实现相同的功能。简单Case函数的写法相对比较简洁 ......

升级oracle中的JDK版本

 
Oracle自8i起就全面支持java,但各个版本的oracle中默认jdk版本均不相同,oracle8i中为 jdk1.2,oracle9i中为jdk1.3,oracle10g中为jdk1.4~~至笔者行为之际,当前的最新版本为jdk1.5 update 11.
因笔者java开发出身,在做oracle开发中经常会用java来扩展 oracle功能,但是由于oracle自带jdk版本过低,可能会造成一些 ......

oracle 常用查询命令

 数据字典dict总是属于Oracle用户sys的。
1、用户:
 select username from dba_users;
改口令
 alter user spgroup identified by spgtest;
2、表空间:
 select * from dba_data_files;
 select * from dba_tablespaces;//表空间
 select tablespace_name,sum(bytes), sum(blocks)
from dba_ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号