First, connect the database
1, start Sql*plus, but do not log in
sqlplus/nolog
2. Connect to Oracle with SYSDBA role
Connect Username/password as Sysdba (provided the user has SYSDBA privileges)
3, direct connection with the SYS user l Connect database
sqlplus/as sysdba
Second, launch the example
1>, start an instance, assemble and open a database
STARTUP; or STARTUP pfile= ' D:/oracle/admin/mydb/scripts/initmydb.ora ';
2>, starting an instance but not assembling a database-a typical application creates a database
STARTUP Nomount;
3>, launches an instance, assembles the database but does not open
--This mode allows you to perform specific maintenance operations, including renaming the database, adding or removing or renaming log files, enabling and deactivating the Redo archive log file option, and performing a full database recovery
STARTUP MOUNT;
4>, restricting access to a database at boot time
--This mode enables the administrator to use the database, but the general operator is not available to perform import and export, perform sql*loader data loading, temporarily prevent typical users from using data promotion or upgrade, in normal mode, have CREATE session system privileges Users can access data by connecting to the database restriction mode while having both the CREATE session and the RESTRICTED session System privilege
STARTUP RESTRICT;
--Change the running normal mode to restricted mode
ALTER SYSTEM DISABLE RESTRICTED SESSION;
--Close restriction mode
ALTER SYSTEM ENABLE RESTRICTED SESSION;
5>, forcing an instance to start (for startup problems, less use, use with caution!) )
STARTUP Force;
6>, launching instances, assembling databases, and initiating full media recovery
STARTUP OPEN RECOVER;
Third, Change Database Availability
1>, Assembly database
ALTER DATABASE MOUNT;
2>, open the database
ALTER DATABASE OPEN;
3>, open a database as read-only or write-only or read/write
ALTER DATABASE OPEN READ only;
ALTER DATABASE WRITE READ only;
ALTER DATABASE OPEN READ WRITE;
Iv. Oracle Database shutdown
1. Normal shutdown
SHUTDOWN NORMAL;
2. Transactional shutdown
--do not allow new connections, but wait for existing transaction execution to end
SHUTDOWN Transactional;
3. Close immediately
SHUTDOWN IMMEDIATE;
4. Forced shutdown
--This mode shuts down the instance recovery process at the next boot
SHUTDOWN ABORT;
5. Pause Database
-typically used for the service of the hour, does not interrupt user operations and does not disrupt database operation, and is less expensive than shutting down the database , only DBA sessions are allowed in this state, and new non-DBA connections are not allowed to establish
ALTER SYSTEM unquiesce;
--Cancel the pause
ALTER SYSTEM QUIESCE RESTRICTED;
--View the paused state of the instance
SELECT active_state from v$instance;
The status of the query:
normal does not pause;
quiescing is paused, but there are still non-DBA sessions;
quiesced has stopped;
6. Suspend database ( usually not used)
--Pauses all IO for data files and control files, can be backed up in the absence of IO interference the pending command can suspend the database without specifying an instance
ALTER SYSTEM SUSPEND;
--Revert to non-suspended state
ALTER SYSTEM RESUME;
--View Pending status
SELECT database_status from V$instance;
Oracle connection startup and shutdown modes (rollup)