ORACLE数据库面试题01_第1页
ORACLE数据库面试题01_第2页
ORACLE数据库面试题01_第3页
ORACLE数据库面试题01_第4页
ORACLE数据库面试题01_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、(1 A 表中有100条记录.这个语句返回几条记录? (简单吧, 似乎1秒钟就有答案了:(2 CREATE SEQUENCE PEAK_NOSELECT PEAK_NO.NEXTVAL FROM DUAL -> 假设返回110秒中后, 再次做SELECT PEAK_NO.NEXTVAL FROM DUAL -> 返回多少?(3 SQL> connect sys as sysdbaConnected.SQL> insert into dual values ( 'Y'1 row created.SQL> commit;Commit complete.

2、SQL> select count(* from dual;COUNT(*-2SQL> delete from dual;commit;->DUAL里还剩几条记录?JUST TRY IT .-【IT168 服务器学院】这里的回答并不是十分全面,这些问题可以通过多个角度来进行解释,也许你不必在面试过程中给出完全详尽的答案,只需要通过你的解答使面试考官了解你对ORACLE 概念的熟悉程度。1. 解释冷备份和热备份的不同点以及各自的优点解答:热备份针对归档模式的数据库,在数据库仍旧处于工作状态时进行备份。而冷备份指在数据库关闭后,进行备份,适用于所有模式的数据库。热备份的优点在于当

3、备份时,数据库仍旧可以被使用并且可以将数据库恢复到任意一个时间点。冷备份的优点在于它的备份和恢复操作相当简单,并且由于冷备份的数据库可以工作在非归档模式下, 数据库性能会比归档模式稍好。(因为不必将archive log写入硬盘)2. 你必须利用备份恢复数据库,但是你没有控制文件,该如何解决问题呢?解答:重建控制文件,用带backup control file 子句的recover 命令恢复数据库。3. 如何转换init.ora 到spfile? 解答:使用create spfile from pfile 命令.4. 解释data block , extent 和 segment 的区别(这里

4、建议用英文术语)解答:data block 是数据库中最小的逻辑存储单元。当数据库的对象需要更多的物理存储空间时,连续的data block就组成了extent . 一个数据库对象拥有的所有extents 被称为该对象的segment.5. 给出两个检查表结构的方法解答:1.DESCRIBE 命令2.DBMS_METADATA.GET_DDL 包6. 怎样查看数据库引擎的报错解答:alert log.7. 比较truncate 和delete 命令解答:两者都可以用来删除表中所有的记录。区别在于:truncate 是DDL 操作,它移动HWK ,不需要 rollback segment .而D

5、elete 是DML 操作, 需要rollback segment 且花费较长时间.8. 使用索引的理由解答:快速访问表中的data block9. 给出在STAR SCHEMA中的两种表及它们分别含有的数据解答:Fact tables 和dimension tables. fact table 包含大量的主要的信息而 dimension tables 存放对fact table 某些属性描述的信息10. FACT Table上需要建立何种索引?解答:位图索引 (bitmap index)11. 给出两种相关约束?解答:主键和外键12. 如何在不影响子表的前提下,重建一个母表解答:子表的外键强

6、制实效,重建母表,激活外键13. 解释归档和非归档模式之间的不同和它们各自的优缺点解答:归档模式是指你可以备份所有的数据库 transactions 并恢复到任意一个时间点。非归档模式则相反,不能恢复到任意一个时间点。但是非归档模式可以带来数据库性能上的少许提高.14. 如何建立一个备份控制文件?解答:Alter database backup control file to trace.15. 给出数据库正常启动所经历的几种状态 ?解答:STARTUP NOMOUNT 数据库实例启动STARTUP MOUNT 数据库装载STARTUP OPEN 数据库打开16. 哪个column 可以用来区

7、别V$视图和GV$视图?解答: INST_ID 指明集群环境中具体的 某个instance 。17. 如何生成explain plan?解答:运行utlxplan.sql. 建立plan 表针对特定SQL 语句,使用 explain plan set statement_id = 'tst1' into plan_table运行utlxplp.sql 或 utlxpls.sql 察看explain plan18. 如何增加buffer cache的命中率?解答:在数据库较繁忙时,适用buffer cache advisory 工具,查询v$db_cache_advice . 如

8、果有必要更改,可以使用 alter system set db_cache_size 命令19. ORA-01555的应对方法?解答:具体的出错信息是snapshot too old within rollback seg , 通常可以通过增大rollback seg 来解决问题。当然也需要察看一下具体造成错误的SQL 文本20. 解释$ORACLE_HOME和$ORACLE_BASE的区别?解答:ORACLE_BASE是oracle 的根目录,ORACLE_HOME是oracle 产品的目录。=SQL 面试2008年04月13日 星期日 00:48面试中的问题,总结起来看,一是关于怎样找出和

9、去除重复数据,这在另一个帖子利已有详细介绍。二是关于找出某一列里最大或最小的前几个,或是大于或小于某一个值(最大值或平均值)的数据。10 学生成绩表grade 中有字段score (float ), 现在要把所有在55分至60之间的分数提高5分,以下sql 语句正确的是()。(选择两项)aUpdate grade set score=score+5bUpdate grade set score=score+5 where score>=55 or score <=60cUpdate grade set score=score+5 where score between 55 and

10、 60dUpdate grade set score=score+5 where score >=55 and score <=6011 现有书目表book ,包含字段:price (float; 现在查询一条书价最高的书目的详细信息,以下语句正确的是()。(选择两项)aselect top 1 * from book order by price ascbselect top 1 * from book order by price desccselect top 1 * from book where price= (select max (pricefrom bookdsel

11、ect top 1 * from book where price= max(price13 查询student 表中的所有非空email 信息, 以下语句正确的是()。(选择一项)aSelect email from student where email !=nullbSelect email from student where email not is nullcSelect email from student where email <> nulldSelect email from student where email is not null15 现有订单表orde

12、rs ,包含用户信息userid, 产品信息 productid, 以下()语句能够返回至少被订购过两回的productid? (选择一项)aselect productid from orders where count(productid>1bselect productid from orders where max(productid>1cselect productid from orders where having count(productid>1 group by productid_dselect productid from orders group b

13、y productid having count(productid>1-18. SQL Server常用测试题(2问题描述:已知关系模式:S (SNO,SNAME 学生关系。SNO 为学号,SNAME 为姓名C (CNO,CNAME,CTEACHER 课程关系。CNO 为课程号,CNAME 为课程名,CTEACHER 为任课教师SC(SNO,CNO,SCGRADE 选课关系。SCGRADE 为成绩1. 找出没有选修过“李明”老师讲授课程的所有学生姓名-实现代码:SELECT SNAME FROM SWHERE NOT EXISTS(SELECT * FROM SC,C WHERE SC

14、.CNO=C.CNO AND CNAME='李明' AND2. 列出有二门以上(含两门 不及格课程的学生姓名及其平均成绩-实现代码:FROM S,SC,(SELECT SNO FROM SC WHERE SCGRADE<60 GROUP BY SNO3. 列出既学过“1”号课程,又学过“2”号课程的所有学生姓名-实现代码:FROM S,(SELECT SC.SNO FROM SC,CWHERE SC.CNO=C.CNO AND C.CNAME IN('1','2'GROUP BY SNOHA VING COUNT(DISTINCT CNO=

15、24. 列出“1”号课成绩比“2”号同学该门课成绩高的所有学生的学号-实现代码:FROM S,(FROM SC SC1,C C1,SC SC2,C C2WHERE SC1.CNO=C1.CNO AND C1.NAME='1'AND SC2.CNO=C2.CNO AND C2.NAME='2'5. 列出“1”号课成绩比“2”号课成绩高的所有学生的学号及其“1”号课和“2”号课的成绩-实现代码:SELECT S.SNO,S.SNAME,SC.1号课成绩,SC.2号课成绩FROM S,(FROM SC SC1,C C1,SC SC2,C C2WHERE SC1.CNO

16、=C1.CNO AND C1.NAME='1'AND SC2.CNO=C2.CNO AND C2.NAME='2'19. Question 1:Can you use a batch SQL or store procedure to calculating the Number ofDays in a Month找出当月的天数select datepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year(getdate( asvarchar+'-'+cast(month(getdate( as varc

17、har+'-01' as datetime20. Question2:Can you use a SQL statement to calculating it!How can I print "10 to 20" for books that sell for between $10 and $20,"unknown" for bookswhose price is null, and "other" for all other prices?select bookid,bookname,price=case whe

18、n price is null then 'unknown'when price between 10 and 20 then '10 to 20' else price endfrom books21. Question3:Can you use a SQL statement to finding duplicate values!How can I find authors with the same last name?You can use the table authors in datatabase pubs. I want to get the

19、result as below:Output:au_lname number_dups- -Ringer 2(1 row(s affectedAnswer 3select au_lname,number_dups=count(1 from authors group by au_lname22. Question4:Can you create a cross-tab report in my SQL Server!How can I get the report about sale quality for each store and each quarter and the total

20、salequality for each quarter at year 1993?You can use the table sales and stores in datatabase pubs.Table Sales record all sale detail item for each store. Column store_id is the id of each store,ord_date is the order date of each sale item, and column qty is the sale qulity. Table stores recordall

21、store information.I want to get the result look like as below:Output:stor_name Total Qtr1 Qtr2 Qtr3 Qtr4- - - - - -Barnum's 50 0 50 0 0Bookbeat 55 25 30 0 0Doc-U-Mat: Quality Laundry and Books 85 0 85 0 0Fricative Bookshop 60 35 0 0 25Total 250 60 1650 25Answer 4:用动态SQL 实现23. Question5: The Fast

22、est Way to Recompile All Stored ProceduresI have a problem with a database running in SQL Server 6.5 (Service Pack 4. We moved the database (object transfer from one machine to another last night, and an error (specific to a stored procedure is cropping up. However, I can't tell which procedure

23、is causing it. Permissions are granted in all of our stored procedures; is there a way from the isql utility to force all stored procedures to recompile?Tips: sp_recompile can recomplie a store procedure each timeAnswer 5:在执行存储过程时, 使用 with recompile 选项强制编译新的计划;使用sp_recompile系统存储过程强制在下次运行时进行重新编译24. Q

24、uestion6: How can I add row numbers to my result set?In database pubs, have a table titles , now I want the result shown as below,each row have a row number, how can you do that?Result:line-no title_id- -1 BU10322 BU11113 BU20754 BU78325 MC22226 MC30217 MC30268 PC10359 PC888810 PC999911 PS137212 PS2

25、09113 PS210614 PS333315 PS777716 TC321817 TC420318 TC7777Answer 6:-SQL 2005的写法select row_number( as line_no ,title_id from titles-SQL 2000的写法select line_no identity(int,1,1,title_id into #t from titlesselect * from #tdrop table #t25. Question 7: Can you tell me what the difference of two SQL stateme

26、nts at performance of execution?Statement 1:if NOT EXISTS ( select * from publishers where state = 'NY'beginSELECT 'Sales force needs to penetrate New York market'endelsebeginSELECT 'We have publishers in New York'endStatement 2:if EXISTS ( select * from publishers where stat

27、e = 'NY'beginSELECT 'We have publishers in New York'endelsebeginSELECT 'Sales force needs to penetrate New York market'endAnswer 7:不同点:执行时的事务数, 处理时间, 从客户端到服务器端传送的数据量大小26. Question8: How can I list all California authors regardless of whether they have written a book?In databa

28、se pubs, have a table authors and titleauthor , table authors has a column state, and titleauhtor have books each author written.CA behalf of california in table authors.Answer 8:select * from authors where state='CA'27. Question9: How can I get a list of the stores that have bought both 

29、9;bussiness' and 'mod_cook' type books?In database pubs, use three table stores,sales and titles to implement this requestment. Now I want to get the result as below:stor_id stor_name- -.7896 Fricative Bookshop. . Answer 9: select distinct a.stor_id, a.stor_name from stores a,sales b,tit

30、les c where a.stor_id=b.stor_id and b.title_id=c.title_id and c.type='business' and exists(select 1 from sales k,titles g where stor_id=b.stor_id and k.title_id=g.title_id and g.type='mod_cook' 28. Question10: How can I list non-contignous data? In database pubs, I create a table test using statement as below, and I insert several row as below create table test ( id int primary key go insert into test values (1 insert into test values (2 insert into test values (3 insert into test values (4 insert into test values (5 insert into test v

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论