本篇文章給大家?guī)砹岁P(guān)于oracle數(shù)據(jù)庫的開啟和關(guān)閉的相關(guān)知識,希望對大家有幫助。
關(guān)于數(shù)據(jù)庫的各種啟動和關(guān)閉命令一直感覺有些混亂,現(xiàn)整理一下。
一、數(shù)據(jù)庫的啟動 :
Oracle 的啟動分為三個步驟:分別是啟動實例、加載數(shù)據(jù)庫 、打開數(shù)據(jù)庫??梢愿鶕?jù)自己的實際需要來開啟數(shù)據(jù)庫
語法是startup
1、nomount 模式
SQL> startup nomount ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 536874104 bytes Database Buffers 285212672 bytes Redo Buffers 6586368 bytes
這種啟動方式只創(chuàng)建實例(即創(chuàng)建Oracle實例的各種內(nèi)存結(jié)構(gòu)和服務(wù)進程),并不加載數(shù)據(jù)庫也不會打開數(shù)據(jù)文件。
這種模式一般適用于在創(chuàng)建數(shù)據(jù)庫和控制文件。
2、mount 模式
SQL> startup mount ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 536874104 bytes Database Buffers 285212672 bytes Redo Buffers 6586368 bytes Database mounted.
這種模式將啟動實例,加載數(shù)據(jù)庫并保存數(shù)據(jù)庫的關(guān)閉模式
一般用于數(shù)據(jù)庫維護時,比如:執(zhí)行數(shù)據(jù)庫完全恢復(fù)操作,更改數(shù)據(jù)庫的歸檔模式等
3、open 模式
SQL> startup ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 536874104 bytes Database Buffers 285212672 bytes Redo Buffers 6586368 bytes Database mounted. Database opened.
這種模式就是將啟動實例,加載并打開數(shù)據(jù)庫。 這是常規(guī)的打開數(shù)據(jù)庫的方式,只要用戶想要對數(shù)據(jù)庫進行多種操作,必須采取這種方式打開,(用open模式打開數(shù)據(jù)庫)startup后面不需要加參數(shù)的。
4、force 模式
SQL> startup force ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 536874104 bytes Database Buffers 285212672 bytes Redo Buffers 6586368 bytes Database mounted. Database opened.
這種模式將終止實例并重新啟動數(shù)據(jù)庫(open),這種模式具有一定的強制性(比如在其他啟動模式失效的時候可以嘗試這種模式)
二 、數(shù)據(jù)庫的關(guān)閉:
關(guān)閉也分為三步,包括:關(guān)閉數(shù)據(jù)庫、卸載數(shù)據(jù)庫、關(guān)閉Oracle實例
語法是shutdown
1、normal
SQL> shutdown normal Database closed. Database dismounted. ORACLE instance shut down.
這種屬于正常關(guān)閉模式(前提沒有時間限制、通常會選擇這種方式來關(guān)閉數(shù)據(jù)庫)
2、immediate
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down.
這種方式成為立即關(guān)閉數(shù)據(jù)庫,盡可能在最短的時間里關(guān)閉數(shù)據(jù)庫。
在這種關(guān)閉方式下,Oracle不但會立即中斷當(dāng)前用戶的連接,而且會強行終止用戶的當(dāng)前活動事物,將未完成的事物回退,以立即關(guān)閉方式關(guān)閉數(shù)據(jù)庫。
3、transactional
SQL> shutdown transactional Database closed. Database dismounted. ORACLE instance shut down.
這種方式稱作為事物關(guān)閉方式,它的首要任務(wù)是要能保證當(dāng)前所有的活動事物都可以被提交并在最短的時間內(nèi)關(guān)閉數(shù)據(jù)庫。
4、abort
SQL> shutdown abort ORACLE instance shut down. 慎重!慎重!慎重?。ㄖ匾氖虑檎f三遍)
這種方式被稱為終極關(guān)閉方式,終極關(guān)閉方式具有一定的強制性和破壞性,使用這種方式會強制中斷任何數(shù)據(jù)庫操作,這樣可能會丟失一部分?jǐn)?shù)據(jù)信息,影響到數(shù)據(jù)庫的完整性。
(如果其他三種方法無法關(guān)閉時再使用此方法。 謹(jǐn)慎使用?。?/p>
推薦教程:《Oracle教程》