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% sqlplus /nolog
SQL> conn / as sysdba
数据库的物理文件
数据文件
select file_name from dba_data_files;
控制文件
select name from v$controlfile;
日志文件
select member from v$logfile;
---------------------------------------------------------
......
一、设置初始化参数 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 用法介绍
包含以下子过程:
......
导读:
2009年9月Oracle公司发布了期待已久的Oracle 11g R2,本系列文章将给读者一一揭开新版本中的新特性,并会介绍企业如何利用这些新特性将现有的Oracle 9i,10g,11g R1升级到Oracle 11g R2.
经历了难以忍受的长时间等待,Oracle公司突然在9月1发布了Oracle 11g R2,我不得不承认Oracle的保密工作做得 ......
(1) v$sql
一条语句可以映射多个cursor,因为对象所指的cursor可以有不同用户(如例1)。如果有多个cursor(子游标)存在,在V$SQLAREA为所有cursor提供集合信息。
例1:
这里介绍以下child cursor
user A: select * from tbl
user B: select * from tbl
大家认为这两条语句是不是一样的啊,可能会有很多人会说是一样 ......
本视图包括Shared pool中SQL语句的完整文本,一条SQL语句可能分成多个块被保存于多个记录内。
V$SQLTEXT中的常用列
HASH_VALUE:SQL语句的Hash值
ADDRESS:sql语句在SGA中的地址
SQL_TEXT:SQL文本。
PIECE:SQL语句块的序号
V$SQLTEXT中的连接列
Column View   ......