Oracle442 application scenarios ---------- database instances and access Database Application Instances
The Application Scenario 1-7 is the installation process of Oracle. Here, I will explain a lot about it. There are a lot of materials on the Internet and it may be added later.
Application Scenario 8
View the location of all data files:
Select name from v $ DATAFILE;
List command:
LIST
SAVE command:
Save d: \ ORACLESQL. SQL;
Application Scenario 9-16: Database uninstallation and configuration process
----------------- Database instance ------------------
Instance: A group of Oracle background processes/threads and a shared memory zone. These memories are shared by threads/processes running on the same computer. Here, you can maintain easy-to-lose and non-persistent content (some can be refreshed and output to the disk ). Database instances can exist even if there is no disk storage. Maybe the instance is not the most useful thing in the world, but you can think of it as the most useful thing, which helps draw a line between the instance and the database.
The following describes how to start a xxx instance, connect to the database, open the database, close the database, unmount the database, and close the instance.
1. To perform the preceding operations, the oracle listener must be started first so that we can connect to the oracle server. Run the following command: lsnrctl start;
2. Start oracle. In windows, oracle is usually started in the service. Generally, related instances are started at the same time. However, you can also choose not to start any specified instance when starting oracle, in this way, oracle can be started quite quickly.
3. Set the instance to be started. In the console window, enter set oracle_sid = xxx (use the export command in unix)
4. Use the/nolog method to enter sqlplus. In the console window, enter sqlplus/nolog, and press enter to enter the sqlplus environment.
5. Enter the connect sys as sysdba command and press enter to enter the password. Press enter to connect to the free oracle instance as sysdba.
6. Enter the command startup nomount and press enter to start the xxx instance, which is set by set oracle_sid = xxx.
7. Enter the alter database mount command and press enter to connect the corresponding database to the xxx instance.
8. Enter the command alter database open and press enter to open the corresponding database.
9. Enter the command shutdown to close the database, unmount the database, and shut down the instance.
The four statuses of the Oracle database instance are OPEN, CLOSE, MOUNT, and NOMOUNT ).
Bytes ------------------------------------------------------------------------------------
Application Scenario 17: Shut down the database instance normally
Use the SHOWDOWN command to close the database instance:
Shutdown normal (the normal parameter is the default parameter)
Open sqlplus:
Cmd-> input in the Command window-> SQLPLUS/NOLOG
(Open sqlplus but not logged on, not connected to the database)
Connect to the database as an administrator:
Conn sys as sysdba; (this will be frequently used later. Use sys to log on AS an administrator)
Use the SHUTDOWN command ---------- as the Postmaster with caution
However, this method is relatively slow and is generally not used.
Application Scenario 18: immediately shut down database instances
SHOWDOWN IMMEDIATE
Application Scenario 19: Shutting Down database instances through transaction processing
SHUTDOWN TRANSACTIONAL
Application Scenario 20: terminate a database instance
SHUTDOWN ABORT
Application Scenario 21: Disable database instances in Enterprise Manager
Closes database instances through the PHP graphical interface control terminal
Application Scenario 22: Start a database instance, load and open a database instance:
Only the system administrator has the permission to shut down the database instance. Therefore, you need to use the sys user to connect to SQL Plus as the system administrator. ---- Run the STARTUP command to start the database instance, load and open the database instance.
Application Scenario 23: Start an instance with the specified initialization meal Data File
You can use the PFILE clause in the start command to specify the initialization parameter file for historical database use.
SPFILE = C: \ Users \ Administrator \ Desktop \ Software 12-Oracle \ source code \ 4.1.4 section \ initoradb. ora
Use the SYS user to connect to SQL Plus as the administrator SYSDBA. If the database is in the starting state, you can use the shutdown immediate mentioned in Application Scenario 18 to close the database and then execute the following command.
Startup pfile = C: \ Users \ Administrator \ Desktop \ Software 12-Oracle \ source code \ 4.1.4 section \ initoradb. ora
Application Scenario 24: Start a database instance without loading the database
Startup nomount ----> you can start a database instance to perform operations such as intermediate databases or data files.
Application Scenario 25: Start a database instance and load a database
Startup mount -----> If the database is not enabled, you can perform database log archiving, database media restoration, data file relocation, and log file redo operations.
Application Scenario 26: Force start of a data instance
If the current database instance cannot be shut down normally and another database instance needs to be started, you need to use the option to force shut down the database instance.
Log On As the sys user administrator. Connect SQL Plus,
Startup force --- stop the current database instance and start a new database instance.
This command is equivalent to the previous shutdown abort command, and then runs STARTUP.
Application Scenario 27: Start a database instance in restricted mode
In the following cases, you must start the database instance in the restricted mode.
1. Execute database operations (in this case, other common users should not access the database to avoid data inconsistency) 2. Use SQL * LOader to extract data in the database. 3. the user must be denied from accessing the database. 4. Port or upgrade the database.
Use
STARTUP RESTRICT
Statement to start the database instance in restricted mode. At this time, only users with restrict session permission can access the database.
Application Scenario 28: Start media recovery when the database is started
To restore the media, use
STARTUP RECOBER
The Recovery Program is automatically executed.
Application Scenario 29: Use the alter database command to change the Startup Mode
1. Switch the mount mode.
The startup nomount command starts the database instance and executes tasks such as rebuilding the database and data files. After the execution is complete, you can load the database instance. Run the following command:
Alter database mount;
2. Switch to OPEN mode. After the above operations are completed, the database instance is still closed. You need to OPEN the database instance and execute the following command
Alter database open;
To prevent user transactions from modifying data in the database, you can open the database in read-only mode,
Alter database open read only; ----> A Problem
Application Scenario 30: Pause Database
When a database is paused, the database is changed to a "paused" state. When the database is in this State, only dba users (sys and system) can execute transactions, queries, and pl/SQL statements, while common users cannot perform these operations. Pause database can be used
Alter system quiesce restricted
Command,
Changed to normal status.
Alter system unquiesce
Command.
View the activity status of the database instance at this time:
Select active_state from v $ instance
Application Scenario 31: Suspending Database
To disable I/o operations on data files and control files, you can use
Alter system suspend
Command to pause the database. To continue normal I/o operations, you can use
Alter system resume
Command.
View the activity status of the database instance at this time:
Select active_state from v $ instance