--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 的简单命令之五的更多相关文章

  1. PLSQL 的简单命令之三

    -- 查找两个表中ID相等的 select a.id, a.name,b.math from stu a,scores b where a.id = b.id -- 右外连接 select b.id, ...

  2. PLSQL 的简单命令之四

    -- 子查询 -- in 等于表中的任意一个 select * from Stu where id in (select id from scores) -- 和子查询返回结果中的某一个值比较成立即可 ...

  3. PLSQL 的简单命令之二

    --1. 查询工资大于12000的员工姓名和工资 --2. 查询员工号为176的员工的姓名和部门号 ' --3. 选择工资不在5000到12000的员工的姓名和工资 --4. 选择雇用时间在1998- ...

  4. Apache 的搭建及vim的简单命令

    一. vim 简单命令 pwd     当前路径 ls    当前路径所有目录 cd  目录地址   跳转到指定目录 /xxx  查找xxx x 删除当前字符 n 执行上一次查找 二.为什么使用apa ...

  5. ORACLE的安装与网页版创建表空间的简单操作以及PLsql的简单操作

    1.oracle的安装: 安装简单易学,在这里不做解释.下载看装包后耐心等待,注意安装目录不要有中文字符,尽量按照指定目录进行安装.安装完成后会占用有大约5g的内存. 如果要卸载oracle,需要用其 ...

  6. 从零单排Linux – 1 – 简单命令

    从零单排Linux – 1 – 简单命令 Posted in: Linux 从零单排Linux – 1 一.Linux的简单命令: 1.忘记root密码: 读秒时按任意键进入 – e – ↓选择第二个 ...

  7. Kafka学习(一)配置及简单命令使用

    一. Kafka中的相关概念的介绍 Kafka是一个scala实现的分布式消息中间件,当中涉及到的相关概念例如以下: Kafka中传递的内容称为message(消息),message 是通过topic ...

  8. Kafka配置及简单命令使用

    一. Kafka中的相关概念的介绍 Kafka是一个scala实现的分布式消息中间件,其中涉及到的相关概念如下: Kafka中传递的内容称为message(消息),message 是通过topic(话 ...

  9. Linux的简单命令

    Linux的简单命令 1.更改linux服务器的登录密码 成功登录后输入命令: passwd 然后按照提示操作即可 2.在当前路径下新建文件夹:mkdir 新建文件夹名 3.解压和压缩文件tar.gz ...

随机推荐

  1. 相关css 细节处理 neat.css

    人性化的细节处理 例如: textarea 默认只能垂直拖动,防止宽度改变破坏布局. textarea { resize: vertical; } 汉字字号小于 12px 不易阅读,为 <sma ...

  2. zend framerwork2.X系列安装创建应用

    1. 到https://github.com/zendframework/ZendSkeletonApplication下载zip包,解压到你服务器的根目录. 2. 打开windows的cmd,cd到 ...

  3. 【转】个人对JQuery Proxy()函数的理解

    原文地址:http://www.cnblogs.com/acles/archive/2012/11/20/2779282.html JQuery.proxy(function,context): 使用 ...

  4. Ubuntu安装Tcpdump

    参考:ubuntu下安装Tcpdump并使用 请先安装libpcap等,可以参照上文链接. 安装: 网址:http://www.tcpdump.org/ 解压: tar -zxvf tcpdump-4 ...

  5. cURL 学习笔记与总结(5)用 cURL 访问 HTTPS 资源

    <?php $curlobj = curl_init(); // 初始化 curl_setopt($curlobj, CURLOPT_URL, "https://ajax.aspnet ...

  6. 微信的User-Agent

    Mozilla/5.0 (Linux; U; Android 5.0.2; zh-cn; MI 2C Build/LRX22G) AppleWebKit/533.1 (KHTML, like Geck ...

  7. 纯CSS制作三角(转)

    原原文地址:http://www.w3cplus.com/code/303.html 原文地址:http://blog.csdn.net/dyllove98/article/details/89670 ...

  8. jQuery之换肤与cookie插件

    有时候一个网页可以有多个皮肤进行选择,也就是不同的背景,或是一整套新的css,能使整个页面变成另一种风格. 这个功能可以用jQuery来实现.外加cookie插件.有了cookie,就可以长时间的保存 ...

  9. Virtual Memory DEMAND PAGING - The avoidance of thrashing was a major research area in the 1970s and led to a vari- ety of complex but effective algorithms.

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION With the use of pagin ...

  10. 15 款最好的 C/C++ 编译器和集成开发环境

    我们有很多编程语言来进行 web 开发,比如 Java,.Net,PHP,Ruby,Perl,Python 等等.今天我们主要讨论的是两大古老而又流行的语言: C 和 C++ ,它们有着许多卓越的特性 ...