PLSQL 的简单命令之五
--1. 查询和Zlotkey相同部门的员工姓名和雇用日期
select a.last_name,a.hire_date ,b.department_name
from employees a,departments b
where b.department_name in
(select department_name
from departments, employees
where last_name = 'Zlotkey') --2. 查询工资比公司平均工资高的员工的员工号,姓名和工资。
select job_id,last_name,salary
from employees
where salary > all (select avg(salary) from employees) --3. 查询各部门中工资比本部门平均工资高的员工的员工号, 姓名和工资
select a.job_id,a.last_name,a.department_id,a.salary,b.avgsalary
from employees a,(select avg(salary) as avgsalary,department_id from employees
group by department_id) b
where a.salary > b.avgsalary and a.department_id = b.department_id
/*
其中各部门的平均工资如下
select avg(salary),department_id from employees
group by department_id 别名为b的表(查询结果的表 )
(select avg(salary) as avgsalary,department_id from employees
group by department_id) b
*/ --4. 查询和姓名中包含字母u的员工在相同部门的员工的员工号和姓名
select job_id,last_name,department_id
from employees
where department_id in (select department_id
from employees
where last_name like '%u%') --5. 查询在部门的location_id为1700的部门工作的员工的员工号
select job_id
from employees
where department_id
in (select department_id
from departments
where location_id =1700) --6.查询管理者是King的员工姓名和工资
select manager_id,last_name,salary from employees
where manager_id
in (select employee_id
from employees
where last_name='King'
group by employee_id) --1. 运行以下脚本创建表my_employees
create table my_employees
(id number,
first_name varchar2(10),
last_name varchar2(10),
userid varchar2(10),
salary number
);
--2. 显示表my_employees的结构
select * from my_employees /*3. 向表中插入下列数据
ID FIRST_NAME LAST_NAME USERID SALARY
1 patel Ralph Rpatel 895
2 Dancs Betty Bdancs 860
3 Biri Ben Bbiri 1100
4 Newman Chad Cnewman 750
5 Ropeburn Audrey Aropebur 1550
*/
insert into my_employees values (1,'patel','Ralph','Rpatel',895);
insert into my_employees values (2,'Dancs','Betty','Bdancs',860);
insert into my_employees values (3,'Biri','Ben','Bbiri',1100);
insert into my_employees values (4,'Newman','Chad','Cnewman',750);
insert into my_employees values (5,'Ropeburn','Audrey','Aropebur',1550); --4. 提交
commit --5. 将3号员工的last_name修改为“drelxer”
update my_employees set last_name='drelxer'
where id = 3 --6. 将所有工资少于900的员工的工资修改为1000
update my_employees set salary=1000 where salary < 900 --7. 检查所作的修正
select * from my_employees --8. 提交
commit --9. 删除所有数据
delete from my_employees --10. 检查所作的修正
select * from my_employees --11. 回滚
rollback --12. 清空表my_employees
truncate table my_employees
PLSQL 的简单命令之五的更多相关文章
- PLSQL 的简单命令之三
-- 查找两个表中ID相等的 select a.id, a.name,b.math from stu a,scores b where a.id = b.id -- 右外连接 select b.id, ...
- PLSQL 的简单命令之四
-- 子查询 -- in 等于表中的任意一个 select * from Stu where id in (select id from scores) -- 和子查询返回结果中的某一个值比较成立即可 ...
- PLSQL 的简单命令之二
--1. 查询工资大于12000的员工姓名和工资 --2. 查询员工号为176的员工的姓名和部门号 ' --3. 选择工资不在5000到12000的员工的姓名和工资 --4. 选择雇用时间在1998- ...
- Apache 的搭建及vim的简单命令
一. vim 简单命令 pwd 当前路径 ls 当前路径所有目录 cd 目录地址 跳转到指定目录 /xxx 查找xxx x 删除当前字符 n 执行上一次查找 二.为什么使用apa ...
- ORACLE的安装与网页版创建表空间的简单操作以及PLsql的简单操作
1.oracle的安装: 安装简单易学,在这里不做解释.下载看装包后耐心等待,注意安装目录不要有中文字符,尽量按照指定目录进行安装.安装完成后会占用有大约5g的内存. 如果要卸载oracle,需要用其 ...
- 从零单排Linux – 1 – 简单命令
从零单排Linux – 1 – 简单命令 Posted in: Linux 从零单排Linux – 1 一.Linux的简单命令: 1.忘记root密码: 读秒时按任意键进入 – e – ↓选择第二个 ...
- Kafka学习(一)配置及简单命令使用
一. Kafka中的相关概念的介绍 Kafka是一个scala实现的分布式消息中间件,当中涉及到的相关概念例如以下: Kafka中传递的内容称为message(消息),message 是通过topic ...
- Kafka配置及简单命令使用
一. Kafka中的相关概念的介绍 Kafka是一个scala实现的分布式消息中间件,其中涉及到的相关概念如下: Kafka中传递的内容称为message(消息),message 是通过topic(话 ...
- Linux的简单命令
Linux的简单命令 1.更改linux服务器的登录密码 成功登录后输入命令: passwd 然后按照提示操作即可 2.在当前路径下新建文件夹:mkdir 新建文件夹名 3.解压和压缩文件tar.gz ...
随机推荐
- EasyUI datagrid 在ie8和360兼容模式兼容性问题
问题:easyui中的datagrid在ie8和360兼容模式下显示不出来. 答案:不是easyui的问题.是引入的jquery版本问题.jquery-1.5.1抛异常,这个版本是mvc3自带的jqu ...
- checked Exception和unchecked exception
checked Exception: io,sql等exception,程序无法控制的 unchecked exception: 包括Error与RuntimeException及其子类,如:OutO ...
- CodeForces 625B 字符串模拟+思维
题意 给出字符串a与b 可以将a中的单个字符改为# 问最少改多少次 a中就找不到b了 一开始想的是用strstr 因为如果找到 可以将strstr(a,b)-a+1改成# 即改首字母 用while循环 ...
- jQuery Questions:Front-end Developer Interview Questions
Explain "chaining". Chaining allows us to run multiple jQuery methods (on the same element ...
- 【转载】Http协议
HTTP是一个属于应用层的面向对象的协议,由于其简捷.快速的方式,适用于分布式超媒体信息系统.它于1990年提出,经过几年的使用与发展,得到不断地完善和扩展.目前在WWW中使用的是HTTP/1.0的第 ...
- maven库文件所在目录
C:\Documents and Settings\jgzhang2\.m2\repository
- 大话数据结构(五)(java程序)——顺序存储结构的插入与删除
获得元素操作 对于线性表的顺序存储结构来说,我们要实现getElement操作,即将线性表的第i个位置元素返回即可 插入操作 插入算法思路: 1.如果插入位置不合理,抛出异常 2.如果插入表的长度大于 ...
- Java中调用c/c++语言出现Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.testPrint(Ljava/lang/String;)V...错误
错误: Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.testPrint(Ljava/lang/S ...
- SQL代码创建表例子
create table class ( code ) primary Key, name ) ); create table student ( code ) primary Key, name ) ...
- hive中的常用方法(case,cast,unix_timestamp)
1.case的用法 )格式1 case col when value then '' when value then '' else '' end )格式2 case when col='value' ...