Unit 1 Introduction To An Oracle Database
Unit 1 Introduction To An Oracle Database
DBA:
Each database requires at least one database administrator (DBA). An Oracle
Database system can be large and can have many users. Therefore, database
administration is sometimes not a one-person job, but a job for a group of DBAs
who share responsibility.
Installing and upgrading the Oracle Database server and application tools
Allocating system storage and planning future storage requirements for the
database system
Creating primary database storage structures (tablespaces) after application
developers have designed an application
Creating primary objects (tables, views, indexes) once application
developers have designed an application
Modifying the database structure, as necessary, from information given by
application developers
Enrolling users and maintaining system security
Ensuring compliance with Oracle license agreements
Controlling and monitoring user access to the database
Monitoring and optimizing the performance of the database
Planning for backup and recovery of database information
Maintaining archived data on tape
Backing up and restoring the database
Contacting Oracle for technical support
What is Instance?
An Oracle instance (also known as a database instance) contains the set of Oracle
Database background processes that operate on the stored data and the shared
allocated memory that those processes use to do their work.
The control file must be available for writing by the Oracle database server
whenever the database is open. Without the control file, the database cannot be
mounted and recovery is difficult.
The control file of an Oracle database is created at the same time as the database.
By default, at least one copy of the control file is created during database creation.
On some operating systems the default is to create multiple copies. You should
create two or more copies of the control file during database creation. You might
also need to create control files later, if you lose control files or want to change
particular settings in the control files.
First method:
ADATA\XE\CONTROL01.CTL, C:\APP
\PRATI\PRODUCT\18.0.0\ORADATA\
XE\CONTROL02.CTL
Second Method:
NAME
--------------------------------------------------------------------------------
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\CONTROL01.CTL
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\CONTROL02.CTL
What is Datafiles?
Data files are the operating system files that store the data within the database. The
data is written to these files in an Oracle proprietary format that cannot be read by
other programs. Tempfiles are a special class of data files that are associated only
with temporary tablespaces.
Data block: A data block, also called a database block, is the smallest unit
of I/O to database storage. An extent consists of several contiguous data
blocks. The database uses a default block size at database creation.
NAME
--------------------------------------------------------------------------------
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\SYSTEM01.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\SYSAUX01.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\UNDOTBS01.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\PDBSEED\SYSTEM01.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\PDBSEED\SYSAUX01.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\USERS01.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\PDBSEED\UNDOTBS01.DB
F
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\XEPDB1\SYSTEM01.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\XEPDB1\SYSAUX01.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\XEPDB1\UNDOTBS01.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\XEPDB1\USERS01.DBF
NAME
--------------------------------------------------------------------------------
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\XEPDB2\XE\FB6E968E0D7
D4A91AF312244DAA447D
1\DATAFILE\O1_MF_SYSTEM_KQN0VFHG_.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\XEPDB2\XE\FB6E968E0D7
D4A91AF312244DAA447D
1\DATAFILE\O1_MF_SYSAUX_KQN0VFHG_.DBF
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\XEPDB2\XE\FB6E968E0D7
D4A91AF312244DAA447D
1\DATAFILE\O1_MF_UNDOTBS1_KQN0VFHX_.DBF
The redo log stores a copy of the changes made to the data. If a failure requires a
data file to be restored from backup, then the recent data changes that are missing
from the restored datafile can be obtained from the redo log, so work is never lost.
The redo log is used to recover a database after hardware, software, or media
failure. To protect against a failure involving the redo log itself, the oracle database
can multiplex the redo log so that two or more identical copies of the online redo
log can be maintained on different disks.
Online redolog files which contain the changes made in oracle. But these file have
a size limit, so when this gets filled up this is written to an offline file called as
offline redolog file, also when the database reaches checkpoint even then all the
contents in the online redolog file is written to offline and the online file is ready
for overwriting of data. To archive redo log you must run database in
ARCHIVELOG mode.
MEMBER
--------------------------------------------------------------------------------
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\REDO03.LOG
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\REDO02.LOG
C:\APP\PRATI\PRODUCT\18.0.0\ORADATA\XE\REDO01.LOG
The database consists of both physical structures and logical structures. Because
the physical and logical structures are separate, the physical storage of data can be
managed without affecting access to logical storage structures.
An Oracle instance (also known as a database instance) contains the set of Oracle
Database background processes that operate on the stored data and the shared
allocated memory that those processes use to do their work.
After starting a database instance, the Oracle software associates the instance with
a specific physical database. This is called mounting the database. The database is
then ready to be opened, which makes it accessible to authorized users.
A session represents the state of a current user login to the database instance. For
example, when a user starts SQL*Plus, the user must provide a valid username and
password, and then a session is established for that user. A session lasts from the
time a user connects until the user disconnects or exits the database application.
Multiple sessions can be created and exist concurrently for a single Oracle
database user using the same username.
By Lec. Pratik Chand, Page 7
Elective-Database Administration – Bsc.CSIT 7th Semester
For example, a user with the username/password of HR/HR can connect to the
same Oracle Database instance several times.
Before you can access the database's contents, you must start Oracle. The
Oracle instance is the collection of memory and processes running which give you
access to the database. If the database server abnormally terminates, the instance
will die. But the data still survives in the database. After the server is up and
running again, one needs to start the instance before they can access the data.
When you start an instance, there are three stages the instance goes through:
1. NOMOUNT: In this mode, only the parameter file (A parameter file is a file
that contains a list of initialization parameters and a value for each parameter like
PROCESSES = 100 OPEN_LINKS = 12 GLOBAL_NAMES = true) is accessed.
Typically, this mode is only used to modify the parameter file's contents or to
create the database.
2. MOUNT: In mount mode, the control files are accessed for the first time.
Certain maintenance operations require the database to be in MOUNT mode.
Mount mode is when the instance acquires memory and spawns the various
background processes required for the Oracle instance.
3. OPEN: This mode is the first mode to touch the datafiles and online redo logs.
Once Oracle has contacted these files, Oracle lets users connect to the instance so
as to interact with the data.
Note: When you issue a normal STARTUP command, the instance proceeds from
NOMOUNT to MOUNT to OPEN. You can STARTUP MOUNT the instance, in
which case the instance goes from NOMOUNT to MOUNT mode, but does not get
to OPEN mode.
A single instance database has the Oracle software, database files, memory and
processes all on one server. A single instance database has a one-to-one
relationship between the instance (memory and processes) and the database
(database files).
Memory structures
Process structures
Storage structures
Memory Structures
Oracle Database creates and uses memory structures for various purposes. For
example, memory stores program code being run, data that is shared among users,
and private data areas for each connected user.
The SGA is the memory area that contains data and control information for the
instance. The SGA includes the following data structures:
Shared pool: Constructs various caches that can be shared among users
Database buffer cache: Caches blocks of data retrieved from the database
Redo log buffer: Caches redo information (used for instance recovery) until
it can be written to the physical redo log files stored on the disk
Large pool: Optional area that provides large memory allocations for
certain large processes, such as Oracle backup and recovery operations, and
I/O server processes
Java pool: Used for all session-specific Java code and data in the Java
Virtual Machine (JVM)
Streams pool: Used by Oracle Streams to store database information in
different location called database replication for data security.
Fixed SGA: An internal housekeeping area containing general information
about the state of the database and the instance, and information
communicated between processes, when you start the instance, the amount
of memory allocated for the SGA is displayed.
A Program Global Area (PGA) is a memory region that contains data and control
information for each server process. An Oracle server process services a client’s
requests. Each server process has its own private PGA that is allocated when the
server process is started. Access to the PGA is exclusive to that server process, and
the PGA is read and written only by the Oracle code acting on its behalf. The PGA
is divided into two major areas: stack space and the user global area (UGA).
The Oracle Database server uses initialization parameters to create and manage
memory structures. The simplest way to manage memory is to allow the database
to automatically manage and tune it for you. To do so (on most platforms), you
only have to set a target memory size initialization parameter
(MEMORY_TARGET) and a maximum memory size initialization parameter
(MEMORY_MAX_TARGET).
Process Structure
The processes in an Oracle Database system can be divided into three major
groups:
When a user runs an application program or an Oracle tool such as SQL*Plus, the
term user process is used to refer to the user’s application. The user process may or
may not be on the database server machine. Oracle Database also creates a server
process to execute the commands issued by the user process. In addition, the
Oracle server also has a set of background processes for an instance that interact
with each other and with the operating system to manage the memory structures,
asynchronously perform I/O to write data to disk, and perform other required tasks.
The process structure varies for different Oracle Database configurations,
depending on the operating system and the choice of Oracle Database options.
The code for connected users can be configured as a dedicated server or a shared
server.
Dedicated server
For each session, the database application is run by a user process that is served by
a dedicated server process that executes Oracle database server code.
Shared server
It eliminates the need for a dedicated server process for each connection. A
dispatcher directs multiple incoming network session requests to a pool of shared
server processes. A shared server process serves any client request.
*RAC (Oracle Real Application Clusters, in this multiple instances shared the
single database)
Server Processes
Oracle Database creates server processes to handle the requests of user processes
connected to the instance. The user process represents the application or tool that
connects to the Oracle database. It may be on the same machine as the Oracle
database, or it may exist on a remote client and use a network to reach the Oracle
database. The user process first communicates with a listener process that creates a
server process in a dedicated environment.
Server processes created on behalf of each user’s application can perform one or
more of the following:
Background Processes
To maximize performance and accommodate many users, a multi-process Oracle
Database system uses some additional Oracle Database processes called
background processes. An Oracle Database instance can have many background
processes.
Control files: A control file is a root file that tracks the physical components
of the database. Each database has one unique control file that contains data
about the database itself (that is, physical database structure information).
Multiple copies may be maintained to protect against total loss. It can also
contain metadata related to backups. The control file is critical to the
database. Without the control file, the database cannot be mounted or
opened.
Data files: Contain the user or application data of the database, as well as
metadata and the data dictionary. A data file is a physical file on disk that
was created by Oracle Database and contains data structures such as tables
and indexes. A temp file is a data file that belongs to a temporary tablespace.
The data is written to these files in an Oracle proprietary format that cannot
be read by other programs.
Online redo log files: Allow for instance recovery of the database. If the
database server crashes and does not lose any data files, the instance can
recover the database with the information in these files.
The following additional files are used during the operation of the database:
Trace files: Each server and background process can write to an associated
trace file. When an internal error is detected by a process, the process dumps
information about the error to its trace file. Some of the information written
to a trace file is intended for the database administrator, whereas other
information is for Oracle Support Services.
Alert log file: These are special trace entries. The alert log of a database is a
chronological (Chronological order is the order in which the events occurred, from
first to last.) log of messages and errors. It is recommended that you review the
alert log periodically.
Above figure shows an entity-relationship diagram for physical and logical storage.
The crow's foot notation represents a one-to-many relationship.
Tablespace:
A tablespace is a logical storage facility (a logical container) for storing objects
such as tables, indexes, sequences, clusters, and other database objects.
By Lec. Pratik Chand, Page 17
Elective-Database Administration – Bsc.CSIT 7th Semester
Each tablespace has at least one physical data file that actually stores the
tablespace at the operating system level. A large tablespace may have more than
one data files allocated for storing objects assigned to that tablespace.
Segment:
A segment is a set of extents allocated for a specific database object, such as
a table. For example, the data for the employees table is stored in its own data
segment, whereas each index for employees is stored in its own index segment.
Every database object that consumes storage consists of a single segment.
When logical storage objects are created within a tablespace, for example and
employee table, a segment is allocated to the object.
Extent:
Each object has one segment which is a physical collection of extents. Extends are
simply collection of contiguous disk storage blocks. A logical storage object such
as a table or index always consists of at least one extent – ideally the initial extent
allocated to an object will be large enough to store all data that is initially loaded.
As a table or index grows, additional extents are added to the segment. A DBA can
add extents to segments in order to tune performance of the system.
Following figure shows the relationships among data blocks, extents, and segments
within a tablespace. In this example, a segment has two extents stored in different
data files.
At the finest level of granularity (level of detail in a set of data), Oracle Database
stores data in data blocks. One logical data block corresponds to a specific number
of bytes of physical disk space, for example, 2 KB. Data blocks are the smallest
units of storage that Oracle Database can use or allocate.
Each segment belongs to one and only one tablespace. Thus, all extents for a
segment are stored in the same tablespace. Within a tablespace, a segment can
include extents from multiple data files, as shown in above Figure. For example,
one extent for a segment may be stored in users01.dbf, while another is stored
in users02.dbf. A single extent can never span data files.
SQL Plus:
SQL Plus is the primary command-line interface to your Oracle database. We can
use SQL Plus to start up and shut down the database, set database initialization
parameters, create and manage users, create and alter database objects such as
tables and indexes, insert and update data, run SQL queries, and more.
Before you submit SQL statements and commands, you must connect to the
database. With SQL Plus, you can connect locally or remotely to the database by
using valid username and password.
The SQL Plus executable on the local computer is provided by a full Oracle
Database installation, an Oracle Client installation, or an Instant Client installation.
You used Oracle Universal Installer (OUI) to install software only, and did
not create a database.
You want to create another database (and database instance) on the same
host computer as an existing Oracle database. In this case, this chapter
assumes that the new database uses the same Oracle home as the existing
database. You can also create the database in a new Oracle home by running
OUI again.
You want to make a copy of (clone) a database.
Assignment
End of Unit-1