In this article I will explain the Oracle Database Architecture. Let’s review the Controlfile Datafile SGA and PGA | Oracle Architecture detailed.
Controlfile Datafile SGA and PGA | Oracle Architecture
Oracle Database is the most preferred database in the world, especially in large scale projects. To be able to learn the Oracle Database in detail, the first thing that should be done is knowing the Oracle Database architecture. So what happens in the background when the user starts a transaction.
When Oracle Database is running, a memory space that we call the shared global area (SGA) on the operating system is allocated to Oracle. At the same time, some processes that we call background processes are started by Oracle to meet the demands of the database. Oracle Instance consists of SGA + Background processes. The following image shows the Oracle Database architecture beautifully. I’ll explain all the concepts through this image.
Control File: The Control file is a file with a .ctl extension that is physically stored on the operating system that is a must for an Oracle database. This file also acts as the brain for our Oracle database. When the Oracle database starts, it reads the parameter file called SPFILE or PFILE and learn the location of the Control file. Because the Control file is the brain of our database, the database needs to find this file to work. If it cannot find the Control File, the Oracle database will not start and will give an error. Thats why, the control file is stored in 2 copies in the production databases. Oracle’s recommended configuration is that we store 3 copies on separate disks. We said the control file is very important. So why is important, what information is in the control file.
- The database name is stored in this file. When the database is opened, it learns what the name of the database is after reading this file.
- It contains the location of Datafile files where the data is physically stored.
- It contains the physical location of the Online Redo log files(transactions are stored in this file) and archive log files(archive of redo log files).
- It contains RMAN backup information. Therefore, if you take a Full backup without backing up the Control file, this backup becomes invalid. It cannot be restored. Therefore, when taking a backup, the Control file must also backed up.
- The current version of the SCN (System Change Number) number used during database operations is also stored in the Control file. SCN is a number that is generated after the transactions are committed. SCN is a unique value that is incrementing in order.
- It contains Checkpoint information. I will explain more about Checkpoint.
- The database creation date is also stored in this file.
- It contains the sequence number of the log files where transactions are stored.
As can be seen from the items I mentioned, the Control file is a must for our Oracle database. That’s why, an Oracle DBA must to know that when he/she takes a backup, control file also must backed up. If we configure RMAN as follows, automatic backup of control file will be active.
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
We can query where the control file is, as follows:
bash-4.1$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 3 11:47:59 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show parameter control_file; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string /oracle/data/TESTDB/control01.ctl, /oracle/data/TESTDB/control02.ctl SQL>
Data Files: These are physical files with the dbf extension that are stored by the Oracle database on the operating system. You can see these files as * .dbf on the operating system. When Oracle database is first created, System, sysaux, undo, user and temp datafiles are created by default. When the user initiates a transaction, Oracle first attempts to find the data that is searched in the Database Buffer Cache. If it cannot find it, it is directed to Data files to find this data. We can see all datafiles belonging to the database with the following query.
bash-4.1$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 3 13:26:26 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> set lines 800 SQL> select FILE_NAME,FILE_ID,TABLESPACE_NAME,BYTES,BLOCKS,MAXBYTES,ONLINE_STATUS from dba_data_files; FILE_NAME FILE_ID TABLESPACE_NAME BYTES BLOCKS MAXBYTES ONLINE_ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------- ------------------------------ ---------- ---------- ---------- ------- /oracle/data/TESTDB/system01.dbf 1 SYSTEM 734003200 89600 3.4360E+10 SYSTEM /oracle/data/TESTDB/sysaux01.dbf 2 SYSAUX 744488960 90880 3.4360E+10 ONLINE /oracle/data/TESTDB/undotbs01.dbf 3 UNDOTBS1 519045120 63360 3.4360E+10 ONLINE /oracle/data/TESTDB/users01.dbf 4 USERS 5242880 640 3.4360E+10 ONLINE /oracle/data/TESTDB/fda01.dbf 5 FDA 1073741824 131072 0 ONLINE SQL>
SGA: When Oracle instance starts, memory area of up to the SGA value specified during the installation phase is allocated by Oracle from the operating system. This memory area is called the System Global Area. This memory space is allocated from the physical server’s RAM until the Oracle instance is closed. When the instance is turned off, this memory space is returned to the operating system.
We determine the SGA value when creating the Oracle database, and the correct and optimum configuration of this value will directly affect oracle’s performance. We can look at the SGA value reserved for Oracle Database as follows.
bash-4.1$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 3 15:31:32 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show parameter sga NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 512M sga_target big integer 512M SQL>
PGA (Program Global Area): This is the memory space allocated from the server’s physical memory when a process is started on an Oracle instance on the server. This memory space is used until the process related to Oracle is terminated. When the process is completed, this memory space is released. You can query the specified value for this memory space in the database as follows.
bash-4.1$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Fri Oct 4 14:56:59 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show parameter pga NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ pga_aggregate_target big integer 2635M SQL>
Shared Pool: Shared Pool is an important memory area used in the vast majority of database operations. Because the query of all the transactions, their execution plans (work plans), the parsed and compiled PL/SQL codes are always stored in this memory area. The shared pool area consists of the following components.
1 nolu sorgu: select * from hr.personel; 2 nolu sorgu: select * from hr.Personel;
SQL> select name,surname,phone from hr.personel where id=1;
In the above query, personel information with an id value of 1 is requested. Imagine that this query is always requested with different id values. Oracle will repeatedly parse this query in the library cache even though the query is the same. So instead of making a soft parse and consuming less than Cpu source, it will make the hard parse and consumes unnecessary CPU resources. At this point, we assign the “bind variable” value for the id column to ensure that the query uses the same execution plan for each different incoming id value. The use of the above query with the bind variable is as follows.
SQL> variable person_id number SQL> exec :person_id : =180251; SQL> select name,surname,phone from hr.personel where id :=person_id;
Dictionary Cache: This memory space stores the metadata of our database.
That is, the following informations is stored in Dictionary cache:
- Who is authorized to access a table
- Tablespace informations
- Column information of a table
This memory space is often used when parsing a query.
So I came to the end of my article. In the next article, I will continue to explain the Oracle Database Architecture.
Read second article by clicking this link.
Do you want to learn Oracle Database for Beginners, then Click and read the following articles.
Oracle Database Tutorials for Beginners ( Junior Oracle DBA )
After reading your blog post, I browsed your website a bit and noticed you aren’t ranking nearly as well in Google as you could be. I possess a handful of blogs myself, and I think you should take a look at “seowebsitetrafficnettools”, just google it. You’ll find it’s a very lovely SEO tool that can bring you a lot more visitors and improve your ranking. They have more than 30+ tools only 20$. Very cheap right? Keep up the quality posts
this sql is wrong written:
select name,surname,phone from hr.personel where id :=person_id;
it should be :
select name,surname,phone from hr.personel where id = :person_id;
yeah you are right, thanks.
Hi
I like to create similar web site like you.
How do I go about this? Please help me. thanks
you want to create any blog or want to design any web site ?