After the database is closed, Oracle Database unmounts the database to disassociate it from the instance. After a database is unmounted, Oracle Database closes the control files of the database. At this point, the instance remains in memory.
3) 实例被shutdown
实例被shutdown。
The final step in database shutdown is shutting down the instance. When the database instance is shut down, the SGA is removed from memory and the background processes are terminated.
数据库关闭的4种模式:ABORT、IMMEDIATE、TRANSACTIONAL、NORMAL。下面的表格介绍了各模式下数据库的行为。
Database BehaviorABORTIMMEDIATETRANSACTIONALNORMALPermits new user connections
No
No
No
No
Waits until current sessions end
No
No
No
Yes
Waits until current transactions end
No
No
Yes
Yes
Performs a and closes open files
No
Yes
Yes
Yes
SHUTDOWN ABORT
This mode is intended for emergency situations, such as when no other form of shutdown is successful. This mode of shutdown is the fastest. However, a subsequent open of this database may take substantially longer because instance recovery must be performed to make the data files consistent.
Note:
Because SHUTDOWN ABORT does not checkpoint the open data files, instance recovery is necessary before the database can reopen. The other shutdown modes do not require instance recovery before the database can reopen.
SHUTDOWN IMMEDIATE
This mode is typically the fastest next to SHUTDOWN ABORT. Oracle Database terminates any executing SQL statements and disconnects users. Active transactions are terminated and uncommitted changes are rolled back.
SHUTDOWN TRANSACTIONAL
This mode prevents users from starting new transactions, but waits for all current transactions to complete before shutting down. This mode can take a significant amount of time depending on the nature of the current transactions.
SHUTDOWN NORMAL
This is the default mode of shutdown. The database waits for all connected users to disconnect before shutting down.
下面通过实例演示Oracle数据库的启动和关闭过程,例子中Oracle版本为11.2.0.1
1、启动数据库
当前没有任何进程和共享内存,设置好ORACLE_SID和ORACLE_HOME环境变量
执行sqlplus / as sysdba连接到一个空实例,当前仍然没有共享内存,只增加了一个进程oracletest的进程
使用startup nomount启动数据库实例,该命令默认查找spfile参数文件启动实例,也可以使用startup nomount pfile='/dir/init.ora'指定参数文件启动,在内存中分配共享内存并创建后台进程。
查看当前的实例状态,当前状态只能查少量的视图如v$instance,但大部分视图无法查询如v$database、v$datafile,会报错:ORA-01507: database not mounted