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 ...
随机推荐
- HDU 1069 基础动态规划+排序
题意 给出n种立方体石头 当且仅当一块石头的底部宽度长度都小于一块石头的时候才能放在上面 问最高能放多高?石头不限数目 然而同样一种石头采用同样的摆放方式 两快相同石头一定无法进行放置 所以 一块石头 ...
- Web 在线文件管理器学习笔记与总结(8)删除文件
unlink($filename) 删除文件 index.php: <?php require 'dir.func.php'; require 'file.func.php'; require ...
- 字符数组char
数组做sizeof的参数不退化,传递给strlen就退化为指针: #include<stdio.h> #include<stdlib.h> #include<strin ...
- Failed to connect to remote VM. Connection refused. Connection refused: connect.
eclipse debug启动经常出现这个错误,已经启动了debug进程,X掉重新启动即可.
- PHP面向对象程序设计的61条黄金法则
PHP面向对象程序设计的61条黄金法则 你不必严格遵守这些原则,违背它们也不会被处以宗教刑罚.但你应当把这些原则看成警铃,若违背了其中的一条,那么警铃就会响起 . ----- Arthur J.R ...
- QQ群笔记
uuid就好比你的名字,类似到了班级里,你的名字会被学号替代.同样的连接之后,uuid会被handle句柄替代. 问下CC2541串口用DMA接收的时候,调试程序时候发现,串口发一帧数据,进入两 ...
- MVC @functions
asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...
- locations in main memory to be referenced by descriptive names rather than by numeric addresses
Computer Science An Overview _J. Glenn Brookshear _11th Edition Chapter 6 Programming Languages As s ...
- [转]EF 4.1 Code First
这篇文章介绍Code First开发以及如何与DbContext API一起使用.Code First允许使用C#或VB.NET类定义模型,在类或属性上有选择性的执行额外的配置或者使用Fluent A ...
- OmniThreadLibrary 3.03b发布了
虽然版本号升的不大,但这也是一个重要的版本.作者发现了一个长期存在的bug,就是建立一个线程,如果不指定线程的优先级则默认设置为idle.(正确的应是Normal) 看一下具体的改动情况: 新功能: ...