数据库查询!!在线急等答案啊
1.有上百万记录随机查询10条记录
2.两个表也是上百万条记录,查询mark字段最大的前十条记录(效率高的方法)
------解决方案--------------------1. select * from 表1 where rownum <=10;
2. select * from 表2 where rownum <=10 roder by mark desc;
------解决方案--------------------1. select * from 表1 where rownum <=10;
2, 以emp表为例:
create or replace function getNo
return varchar2 is
vEmpNo varchar2(20);
iLoop number;
BEGIN
select max(empno) into vEmpNo from emp;
for iLoop in 1..10 loop
select max(empno) into vEmpNo from emp where empno < vEmpNo;
end loop;
return vEmpNo;
END;
/
select empno,ename from emp where empno > getNo;