select to_char(sysdate,’yyyymmddhh24miss’) from dual;
2、查询A表中数据记录的总行数。
select count(*) from A
3、EMP雇员表中有staffno(工号),sala(薪水),indate(入职日期)3个字段。请按日期分组查询出该天入职雇员名单及其薪水。
select staffno,sala ,indate from EMP group by indate,staffno,sala ;
4、EMP雇员表中有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;
---上面的程序还缺少异常处理,后续加上
5、EMP雇员表中有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表里没成绩的连工号没有记录)