資料庫實驗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 學生表;