华为oracle试题解答

1 、查询数据库系统当前时间,以“ 20080416235959 ”的格式输出结果。

select to_char(sysdate,’yyyymmddhh24miss’)  from dual;

2、查询A表中数据记录的总行数。
select count(*) from A

3EMP雇员表中有staffno(工号),sala(薪水)indate(入职日期)3个字段。请按日期分组查询出该天入职雇员名单及其薪水。
select staffno,sala ,indate from EMP group by indate,staffno,sala ;

4EMP雇员表中有staffno(工号),sala(薪水)indate(入职日期)3个字段。请编写一个存储过程,给2006年前入职的员工加薪300元,给2007年入职的员工加薪200元,其他员工加薪100元。

 

create or replace procedure emp_update_sala

as

cursor c_row

is

select * from emp  for update of sala;

begin

for v_row in c_row loop

if(v_row.indate<to_date(' 2007-1-1 ','yyyy-mm-dd')) then update emp set sala=sala+300 where current of c_row;

elsif (v_row.indate>to_date(' 2007-1-1 ','yyyy-mm-dd')) and v_row.indate<to_date(' 2008-1-1 ','yyyy-mm-dd') then

          update emp set sala=sala+200;

else update emp set sala=sala+100 where current of c_row;

end if;

end loop;

commit;--不要忘了这个。

end;

---上面的程序还缺少异常处理,后续加上

 

5EMP雇员表中有staffno(工号),sala(薪水)indate(入职日期)3个字段。SCORE考核成绩表中有staffno(工号),SCORE(分数)两个字段。请查询出没有考核成绩的雇员名单及其入职时间。
方法一:使用外连接:select EMP.staffno,indate from EMP left outer join SCORE using (staffno)  where  SCORE.score is null;
方法二:select staffno,indate from EMP where EMP.staffno not in  (select staffno from SCORE) (这里是指SCORE表里没成绩的连工号没有记录)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值