数据库实验3
『壹』 实验3 数据查询 实验名称:数据查询 目的要求: (1) 掌握SELECT语句的使用 (2) 熟练使用条件查询、多
1.1 create Table Teacher(TNo varchar2(20),
TName varchar2(50),
age number,
sal number,
mgr varchar2(20),
DNo varchar2(20)
);
1.2 insert into Teacher(TNo, TName, Age, Sal, mgr, DNo)
values('0001', '张老师', 45, 100000, '0000', '0001');
2.1 select TNo "教职工号", TName "姓名" from Teacher;
2.2 select TName "姓名", sal "年薪", '元' "币种单位" from Teacher;
3.1 select Tno,TName,age,sal,mgr,DNo
from Teacher
where DNo = '0002';
3.2 select * from 学生表
where to_char(出生日期, 'yyyy') between '1984' and '1985';
3.3 select * from 学生表
where 姓名 like '王%';
4 select Tno,TName,age,sal,mgr,DNo
from Teacher
order by Sal Asc;
5.1 select Sum(sal) "工资总额"
from Teacher;
5.2 select Nvl(TName, '工资总额') "姓名", Sum(sal) "工资"
from Teacher
group by Rollup(TName);
5.3 select Max(Sal) "最高工资", Min(Sal) "最低工资", Avg(Sal) "平均工资"
from Teacher
5.4 select Count(1) "学生总数"
from 学生表;