First, start and close the Oracle database
For most Oracle DBAs, the most common way to start and close the Oracle database is the Server Manager in the command line mode. After Oracle 8i, the system sets all the features of the Server Manager to SQL * Plus, that is, since the start and closing of the database after 8i can be done directly through SQL * PLUS, no longer need Server Manager, but The system still retains the Server Manager tool in order to keep downward compatibility. In addition, the system's startup and closure can be completed by the Oracle Enterprise Manager of the Graphic User Tool (GUI), and the graphical user interface Instance Manager is very simple, and this is no longer detailed here.
To launch and close the database, you must log in with a user with Oracle administrator privilege, usually log in to a user with SYSDBA privileges. Generally we use the internal user to start and close the database (INTERNAL users actually SYS users are synonymous with SYSDBA). The new version of the Oracle database will gradually eliminate internal users, so we'd better set the DBA user has SYSDBA privileges.
Second, the startup of the database (STARTUP)
Start a database requires three steps:
1. Create an Oracle instance (non-installation phase) 2, install the database (installation phase) 3, open the database (open phase)
In the Startup command, you can control the different startup steps of the database through different options.
1, Startup Nomount
The Nonount option only creates an Oracle instance. Read the init.ra initialization parameter file, start the background process, initialize the system's global zone (SGA). The init.ora file defines the configuration of the instance, including the size of the memory structure and the number and type of the startup process. The instance name is set according to the Oracle_sid setting, not necessarily the same as the open database name. When the instance is turned on, a list of SGA memory structures and sizes will be displayed as follows:
SQL> Startup Nomount Oracle routines have been started. Total system global area 35431692 bytes fixed size 70924 bytes variable size 18505728 bytes database buffers 16777216 bytes redo buffers 77824 bytes
2, Startup Mount
This command creates an instance and installs the database, but does not open the database. Oracle system reads the contents of the data files and recall log files in the control file, but does not open the file. This open mode is often used in database maintenance operations, such as rename, change the renovation log, and open archiving methods. In this open mode, in addition to the list of SGA systems, the system will give a prompt to the "Database Load".
3, Startup
This command completes all three steps that create an instance, install instance, and open the database. At this point, the data library makes the data file and the re-log file online, usually requests one or multiple returns. At this time, the system can see all the prompts in the previous Startup Mount mode, and a prompt of "Database has opened" is given. At this point, the database system is in a normal operating state and accepts user requests.
If you use Startup Nomount or the database of Startup Mount to open the command mode, you must use the alter database command to perform the operation of opening the database. For example, if you turn on the database in a Startup Nomount, it means that the instance has been created, but the database is not installed and opened. This is the two commands that must be run, and the database can start correctly. Alter Database Mount; Alter Database Open;
And if you start the database in a Startup Mount, you only need to run the following command to open the database:
ALTER DATABASE OPEN.
4, other open mode
In addition to the three database open mode options, there are other options.
(1) Startup Restrict
In this way, the database will be successfully opened, but only some privileged users (users with DBA roles) can be used to use the database. This way is commonly used to maintain the database, such as data import / export operations, do not want other users to connect to database operation data.
(2) STARTUP FORCE
This command is actually an integrated integration of two commands for arsenciting database (STARTUP) and startup database (STARTUP). This command is only used when closing the database is incoming problems.
(3) Alter Database Open read Only;
This command opens the database in read-only mode after creating an instance and installing the database. This way can be opened for those product databases that only provide query functions.
Third, the shutdown of the database (shutdown) For the shutdown of the database, there are four different closing options, which will be described below.
1, Shutdown Normal
This is the rule of the database to close the Shutdown command. That is to say, if you make a command such as Shutdown, it is the meaning of Shutdown Nornal.
Any new connection will never be connected to the database after emitting this command. Before the database is closed, Oracle will wait for all users currently connected to exit from the database before starting the database. This way to turn off the database and do not need any instance recovery at the next startup. However, it should be noted that this approach is used, and it is possible to close a database a few days, perhaps longer.
2, Shutdown Immediate
This is a way we are commonly used to close the database. I want to shut down the database soon, but I want to turn off the database clean and use this way.
The SQL statement currently being processed by Oracle is interrupted immediately, and anything that is not submitted in the system rolls all. If there is a long uncommitted transaction in the system, it takes a while to shut down the database (this transaction rollback time). The system will not wait for all users who connect to the database to exit the system, forcibly roll back all the active transactions, and disconnect all connection users.
3. Shutdown Transactional
This option is only available after Oracle 8i. This command is often used to turn off the database, which makes the current connection to the system and is active, and any new connection and transactions are not allowed after running the command. After all active transactions are completed, the database will close the database in the same way as Shutdown Immediate.
4, Shutdown Abort
This is the last trick closing the database, and it has to be adopted without any way to close the database. This way to close the database can be considered if the following cases occur.
1. The database is in a non-normal operating state, and the database cannot be turned off with Shutdown Normal or Shutdown Immediate; 2. You need to turn off the database immediately;
3, encounter problems when starting the database instance;
All running SQL statements will be aborted immediately. All unsubedited transactions will not roll back. Oracle does not wait for a user exit system currently connected to the database. When the next time the database is started, the instance is restored, so the next startup may require more time than usual.
Table 1 can clearly see the differences and links of the above four different closing databases.
Table 1 SHUTDOWN database different ways to comparison table
Close Method A I T N allows new connection × × × × waiting until the current session stop × × × √ Wait until the current transaction is stopped × √ √ √ Force CheckPoint, close all file × √ √ √ √ √ √ √
Among them: A-Abort I-Immediate T-Transaction N-NORNAL