问:如何用NORMAL选项关闭数据库?
答:使用shutdown normal命令!
场景一:在执行shutdown normal命令的时候,Oracle是否会主动断开与所有用户的连接?
会话一:
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
会话二:SQL> conn scott/tiger
Connected.
SQL>
切换到会话一:
SQL> shutdown normal
此时,Oracle 将等待所有连接的用户解除与数据库的连接。
切换到会话二:
Connected.
SQL> quit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
[oracle@myCentOs admin]$
切换到会话一:
SQL> shutdown normal
Database closed.
Database dismounted.
ORACLE instance shut down.
结论:在数据库关闭之前, Oracle将等待所有当前连接的用户解除与数据库的连接。
场景二:在执行shutdown normal命令的时候,用户是否可以连接到数据库?
会话一:
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
再运行以下语句:
SQL> shutdown normal
同时,在会话二,运行以下语句:
SQL> conn scott/tiger
此时,会产生如下结果:
会话一:
SQL> shutdown normal
Database closed.
Database dismounted.
ORACLE instance shut down.
会话二:
ERROR:
ORA-01090: shutdown in progress - connection is not permitted
结论:在执行shutdown normal命令的时候,不允许有新的连接。