Database programs generally use computer memory and persistent storage devices (such as disks) for operations. The disk provides space for persistent storage and storage of a large amount of information. However, obtaining information from a disk is much slower than obtaining information from the memory. Therefore, many database engines use the memory to cache information, thus accelerating data access.
How to store and obtain information is transparent for terminal query users. However, if you plan to manage Oracle, you need to be familiar with Oracle processing methods. This article discusses two basic but important concepts related to memory and disk: database and instance.
Database
In Oracle, databases are used to describe the set of physical files used to store information. There are three types of physical files:
- Data Files ------ these files are the main files of the database, including data tables, indexes, and all other segments.
- Control Files-these files tell you where the data files, temporary files, and redo log files are, and indicate other metadata related to the file status.
- Redo-log files (redo-log files)-used to record all changes to the data, which can be used for data backup and recovery.
No matter how many files are used, they are part of the database.
Instance
If the memory structure and background process are not used to operate the database, these database files are meaningless. oralce uses the term instance to define a group of background processes and memory structures used to access the database.
An instance mainly uses two memory structures:
- System global area (SGA), also known as shared gloabl area, is the memory area shared by the Oracle process.
- Program global area (PGA), also known as private global area: private memory area of a specific process.
SGA includes the database cache used to save information read from data files, the data dictionary cache used to save metadata information, and the database cache used to save recently used SQL and PL/SQL statements. PGA is used to allocate memory for the information required by each specific process, including the sorting space, array, and cursor. Instances also include a group of background processes that work together to implement different functions. For example, the database writer processes are responsible for saving all changes to the database. The process monitor is responsible for clearing Failed User processes.
Start the Oracle server:The differences between databases and instances can be seen from the different steps of starting oracle. The first step is to start the instance itself. Different background processes are started and allocated the corresponding memory zone. Step 2: load the database to the instance. Finally, open the database.
Although these steps are usually completed together when oracle is started, sometimes you need to leave oracle at a certain stage. Let's take a look at the related syntax. You can use SQL * Plus to log on to Oracle and try these commands.
Startup or startup open tells Oracle to complete three steps at a time. If you only want to start an oracle instance, you can run the startup nomount command. Oracle will only start the instance but will not load the database, that is, start an empty instance.
Why? Sometimes you may need to create a new control file or database, and these operations must be completed before accessing the database. You can also enter startup Mount (or you have previously entered startup nomount) to tell Oracle to load database files. In this case, the instance will access all information related to the database. However, the user cannot access the database. An example of a required operation is to rename a file used by the system tablespace. After all the modifications are completed, you can enter the alter database open command to allow all users to access the database.