nihaogirl 发表于 2018-9-24 06:08:13

某运营商的oracle笔试题

  今年初本人去某运营商应聘BI开发一职,做了一份笔试题,是本人见过的最有水平的oracle试题,题目很简单,任何人都知道怎么做,但能否做出来就不知道了,见下(时间长了,试题记得不是很清楚了):
  一.用plsql块实现在一个表中插入100000条数据,要求每1000条提交一次,表名自定。
  --很简单,见下(存储过程):
  create or replace procedure p_circle_commit
  as
  begin
  for i in 1..100000 loop
  -- dbms_output.put_line(i);
  insert into test(testid) values(i);
  if mod(i,1000)=0 then
  commit;
  dbms_output.put_line('commit');
  end if;
  end loop;
  end;
  /
  ---执行6.4秒
  ----如果采用批量提交,只要3.3秒:
  create or replace procedure p_circle_commit
  as
  begin
  for i in 1..100000 loop
  -- dbms_output.put_line(i);
  insert into test(testid) values(i);
  end loop;
  commit;--批量提交
  end;
  /
  二. 有3个表 A(userid(用户ID),time(时间),fee(话费)),B(userid(用户ID),time(时间)),C(userid(用户ID),fee(话费))各有1000万的数据, 3个表的userid是相同的,要求用B表的time字段,C表的fee字段更新A表的相应字段,用存储过程实现。
  --基本实现思路(没有条件测试,估计很难实现,有条件也要谨慎,充分考虑效率、表空间、回滚段是否够用等):
  1.要用B、 C的数据更新A,先取userid相同的数据,从A中取userid、B取time、C取fee字段的值,加到新临时表表中
  如:create table tempA-1 as select a.userid,b.time,c.fee
  from A,B,Cwhere a.userid = b.userid and a.userid = c.userid;
  2. 再取A表userid与B、C表userid不相同的数据,直接从A表中取(即B、C表中没有的数据不用更新),再建临时表
  如:create table tempA-2 as select a.userid,a.time,a.fee
  from A,B,Cwhere a.userid != b.userid and a.userid != c.userid;
  3. 把小临时表的数据加到大临时表中:
  Insert into tempA-1(userid,time,fee)   select a.userid,a.time,a.fee tempA-2a where a.time >= '时间值';
  4. 最后将A表与 tempA-1互换名称。
  三。有个上百万的用户信息表,里面有部分重复号码,请删除重复的号码,用存储过程实现。
  --本人简单利用一个录音表来实现没有写存储过程,6万数据很短时间解决,100万数据需要多长时间没有测试。
  1. 建立表:
  create table RECORDFILE
  (
  SERIALNO   VARCHAR2(200),
  FILEPATH   VARCHAR2(400),
  PARTID   VARCHAR2(40),
  STAFFNO    VARCHAR2(100),
  RECORDTIME DATE
  );
  --使用循环加入6万数据
  commit;
  2.创建临时表 ,在6万多数据中查询staffno 不重复的数据,不到1秒时间。
  create table recordfile_temp as
  select * from recordfile t
  where t.serialno in (select max(r.serialno) from recordfile r group by r.staffno);
  --truncate掉原表:
  truncate table recordfile;
  --数据加到原表中,drop掉临时表:
  insert into /*+ append */ recordfile select * from recordfile_temp;
  commit;
  以上仅供参考,不足之处请谅解!
  结果是本人没有通过笔试,哪位能在40分钟能做完(原笔试1小时,还有一些BI基本知识、plsql的内容),可以去运营商那挑战T数量级的应用开发(绝对比那些小数据库开发刺激的多了)。

页: [1]
查看完整版本: 某运营商的oracle笔试题