ORACLE數(shù)據(jù)庫面試題01_第1頁
ORACLE數(shù)據(jù)庫面試題01_第2頁
ORACLE數(shù)據(jù)庫面試題01_第3頁
ORACLE數(shù)據(jù)庫面試題01_第4頁
ORACLE數(shù)據(jù)庫面試題01_第5頁
已閱讀5頁,還剩11頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、(1 A 表中有100條記錄.這個語句返回幾條記錄? (簡單吧, 似乎1秒鐘就有答案了:(2 CREATE SEQUENCE PEAK_NOSELECT PEAK_NO.NEXTVAL FROM DUAL -> 假設(shè)返回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 服務(wù)器學(xué)院】這里的回答并不是十分全面,這些問題可以通過多個角度來進行解釋,也許你不必在面試過程中給出完全詳盡的答案,只需要通過你的解答使面試考官了解你對ORACLE 概念的熟悉程度。1. 解釋冷備份和熱備份的不同點以及各自的優(yōu)點解答:熱備份針對歸檔模式的數(shù)據(jù)庫,在數(shù)據(jù)庫仍舊處于工作狀態(tài)時進行備份。而冷備份指在數(shù)據(jù)庫關(guān)閉后,進行備份,適用于所有模式的數(shù)據(jù)庫。熱備份的優(yōu)點在于當

3、備份時,數(shù)據(jù)庫仍舊可以被使用并且可以將數(shù)據(jù)庫恢復(fù)到任意一個時間點。冷備份的優(yōu)點在于它的備份和恢復(fù)操作相當簡單,并且由于冷備份的數(shù)據(jù)庫可以工作在非歸檔模式下, 數(shù)據(jù)庫性能會比歸檔模式稍好。(因為不必將archive log寫入硬盤)2. 你必須利用備份恢復(fù)數(shù)據(jù)庫,但是你沒有控制文件,該如何解決問題呢?解答:重建控制文件,用帶backup control file 子句的recover 命令恢復(fù)數(shù)據(jù)庫。3. 如何轉(zhuǎn)換init.ora 到spfile? 解答:使用create spfile from pfile 命令.4. 解釋data block , extent 和 segment 的區(qū)別(這里

4、建議用英文術(shù)語)解答:data block 是數(shù)據(jù)庫中最小的邏輯存儲單元。當數(shù)據(jù)庫的對象需要更多的物理存儲空間時,連續(xù)的data block就組成了extent . 一個數(shù)據(jù)庫對象擁有的所有extents 被稱為該對象的segment.5. 給出兩個檢查表結(jié)構(gòu)的方法解答:1.DESCRIBE 命令2.DBMS_METADATA.GET_DDL 包6. 怎樣查看數(shù)據(jù)庫引擎的報錯解答:alert log.7. 比較truncate 和delete 命令解答:兩者都可以用來刪除表中所有的記錄。區(qū)別在于:truncate 是DDL 操作,它移動HWK ,不需要 rollback segment .而D

5、elete 是DML 操作, 需要rollback segment 且花費較長時間.8. 使用索引的理由解答:快速訪問表中的data block9. 給出在STAR SCHEMA中的兩種表及它們分別含有的數(shù)據(jù)解答:Fact tables 和dimension tables. fact table 包含大量的主要的信息而 dimension tables 存放對fact table 某些屬性描述的信息10. FACT Table上需要建立何種索引?解答:位圖索引 (bitmap index)11. 給出兩種相關(guān)約束?解答:主鍵和外鍵12. 如何在不影響子表的前提下,重建一個母表解答:子表的外鍵強

6、制實效,重建母表,激活外鍵13. 解釋歸檔和非歸檔模式之間的不同和它們各自的優(yōu)缺點解答:歸檔模式是指你可以備份所有的數(shù)據(jù)庫 transactions 并恢復(fù)到任意一個時間點。非歸檔模式則相反,不能恢復(fù)到任意一個時間點。但是非歸檔模式可以帶來數(shù)據(jù)庫性能上的少許提高.14. 如何建立一個備份控制文件?解答:Alter database backup control file to trace.15. 給出數(shù)據(jù)庫正常啟動所經(jīng)歷的幾種狀態(tài) ?解答:STARTUP NOMOUNT 數(shù)據(jù)庫實例啟動STARTUP MOUNT 數(shù)據(jù)庫裝載STARTUP OPEN 數(shù)據(jù)庫打開16. 哪個column 可以用來區(qū)

7、別V$視圖和GV$視圖?解答: INST_ID 指明集群環(huán)境中具體的 某個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的命中率?解答:在數(shù)據(jù)庫較繁忙時,適用buffer cache advisory 工具,查詢v$db_cache_advice . 如

8、果有必要更改,可以使用 alter system set db_cache_size 命令19. ORA-01555的應(yīng)對方法?解答:具體的出錯信息是snapshot too old within rollback seg , 通??梢酝ㄟ^增大rollback seg 來解決問題。當然也需要察看一下具體造成錯誤的SQL 文本20. 解釋$ORACLE_HOME和$ORACLE_BASE的區(qū)別?解答:ORACLE_BASE是oracle 的根目錄,ORACLE_HOME是oracle 產(chǎn)品的目錄。=SQL 面試2008年04月13日 星期日 00:48面試中的問題,總結(jié)起來看,一是關(guān)于怎樣找出和

9、去除重復(fù)數(shù)據(jù),這在另一個帖子利已有詳細介紹。二是關(guān)于找出某一列里最大或最小的前幾個,或是大于或小于某一個值(最大值或平均值)的數(shù)據(jù)。10 學(xué)生成績表grade 中有字段score (float ), 現(xiàn)在要把所有在55分至60之間的分數(shù)提高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 現(xiàn)有書目表book ,包含字段:price (float; 現(xiàn)在查詢一條書價最高的書目的詳細信息,以下語句正確的是()。(選擇兩項)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 現(xiàn)有訂單表orde

12、rs ,包含用戶信息userid, 產(chǎn)品信息 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問題描述:已知關(guān)系模式:S (SNO,SNAME 學(xué)生關(guān)系。SNO 為學(xué)號,SNAME 為姓名C (CNO,CNAME,CTEACHER 課程關(guān)系。CNO 為課程號,CNAME 為課程名,CTEACHER 為任課教師SC(SNO,CNO,SCGRADE 選課關(guān)系。SCGRADE 為成績1. 找出沒有選修過“李明”老師講授課程的所有學(xué)生姓名-實現(xiàn)代碼:SELECT SNAME FROM SWHERE NOT EXISTS(SELECT * FROM SC,C WHERE SC

14、.CNO=C.CNO AND CNAME='李明' AND2. 列出有二門以上(含兩門 不及格課程的學(xué)生姓名及其平均成績-實現(xiàn)代碼:FROM S,SC,(SELECT SNO FROM SC WHERE SCGRADE<60 GROUP BY SNO3. 列出既學(xué)過“1”號課程,又學(xué)過“2”號課程的所有學(xué)生姓名-實現(xiàn)代碼: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”號同學(xué)該門課成績高的所有學(xué)生的學(xué)號-實現(xiàn)代碼: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”號課成績高的所有學(xué)生的學(xué)號及其“1”號課和“2”號課的成績-實現(xiàn)代碼: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找出當月的天數(shù)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:用動態(tài)SQL 實現(xiàn)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:在執(zhí)行存儲過程時, 使用 with recompile 選項強制編譯新的計劃;使用sp_recompile系統(tǒng)存儲過程強制在下次運行時進行重新編譯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:不同點:執(zhí)行時的事務(wù)數(shù), 處理時間, 從客戶端到服務(wù)器端傳送的數(shù)據(jù)量大小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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論