Oracle Database Essentials
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
Who am I …
Hi,IamMutebiBashir.
👨🏫 👨💻 👨✍️
Introduction
✓ Databaseadministrationreferstomanagingandmaintainingdatabasesystems.
✓ Databaseadministrationissoimportantforanumberofreasonse.g.reducingcosts,
ensuredatabaseavailability,reputationoftheorganization,etc.
✓ Databaseadministrationiscomprisedofbackingupofdata,databaserecovery,database
auditing,databaseavailability,etc.
✓ ThepeoplechargedwithdatabaseadministrationarereferredtoasDatabase
Administrators(DBA)
What you will learn
✓ Oracle Architecture ✓ Authorization
✓ Oracle software installation ✓ Auditing
✓ Creating Oracle database using DBCA ✓ Performing Database Backup
✓ Managing Oracle Instance ✓ Why database backup
✓ Oracle’sStorageStructures ✓ Backup terminologies
✓ Physical Structures ✓ Backup & Recovery components
✓ Backup database files
✓ Logical Structures
✓ Performing Database Recovery
✓ Managing User Security
✓ Types of database failures.
✓ Authentication
✓ Recovering from various failures
Oracle Architecture
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
Oracle Architecture
✓ Understanding the architecture of Oracle is so key in your journey as a DBA
✓ This topic is all about understanding what is going on in the hood.
✓ For the first part, Oracle database software is divided into two parts i.e. instance and the
database.
✓ The instance is made up of memory and background processes that keep the software
running.
✓ Database is made up of files on a disk e.g. redo log files, data files, etc.
Oracle Architecture – How users connect to database
✓ Whenever a person uses an application that runs on Oracle database software, they
undergo a process before connecting to the database.
✓ Assuming you start an Oracle based app on your device, it has to connect to the
database.
✓ What happens, your device sends a connection request to the database in form of a user
process (initiates connection to the database)
✓ To the other side of the connection, the user is connected to the instance.
Oracle Architecture – How users connect to database
✓ In the instance, a user session is started and the server process is started. Server process
interacts with the database on behalf of the user.
✓ When the server process is started, memory is allocated (Program Global Area - PGA).
Thisworkswithserverprocesstoensureclient’srequestsaresatisfied.
✓ After this (in addition to other things), the user can now access the records in the
database.
Oracle Architecture - Illustration
Server Process + PGA
Connection
1. Instance
2. Database
Data
User Process
Oracle Architecture - Instance
✓ Remember instance is different from the database. The instance is the gateway to the
database. Without it, forget about the database.
✓ The instance is made up of memory and background processes.
✓ Under memory, we have PGA (Program Global Area) and the System Global Area (SGA)
✓ The PGA is a private memory structure charged with storing user session details as well
as working with the server process.
✓ The SGA is a public memory structure with mandatory and option components.
Oracle Architecture – Instance (System Global Area)
Mandatory Components
✓ Database buffer – stores recently modified data blocks temporarily.
✓ Redo log buffer – stores SQL statements that cause a change to data temporarily..
✓ Shared Pool – stores SQL statement execution plan.
Optional Components
✓ Java pool, stream pool, large pool, results cache.
Oracle Architecture – Instance (System Global Area)
✓ Memory can be configured automatically by Oracle or manually by a DBA.
✓ We can set the memory target from which memory will be allocated.
Oracle Architecture – Instance - Illustration
Database buffer
1. Instance Redobuffer
Shared Pool
2. Database Data Redo Control
Etc.
file Log file file
Oracle Architecture – Instance (Background Processes)
Mandatory Background Processes
✓ System Monitor (SMON) – mounts, opens and closes the database.
✓ Process Monitor (PMON) – monitors database background processes.
✓ Database Writer (DBWn) – writes recently modified data blocks to data files (checkpoint
event).
✓ Checkpoint (CKPT) – updates the control files and data file headers about a checkpoint event.
✓ Log Writer (LGWR) – writes SQL statements that cause a change to data to redo log files.
Oracle Architecture – Instance - Illustration
Database buffer
1. Instance Redo buffer
CKPT
DBWn LGWR Shared Pool
2. Database Data Control Redo Log
Etc.
file file file
Oracle Architecture – Instance (Background Processes)
Optional Background Processes
✓ Archiverprocess(ARCn). Chargedwithcopyingtransactionalrecoveryinformationfromthe
redologfiletothearchivelocation.
✓ MemoryManager(MMAN). ManagesthesizeofeachindividualSGAcomponentwhen
Oracle’sAutomaticSharedMemoryManagementfeatureisused.
✓ RecoveryWriter(RVWR).WritesrecoveryinformationtodiskwhenOracle’sFlashback
Databasefeatureisused.
✓ Weusethev$process viewtolookatallrunningprocesses.
Oracle Architecture – Database
✓ Whentheinstancecomponentsareallright,wecannowaccessthedatabase.
✓ Thedatabaseisconcernedwithstorage.
✓ Itismadeupofphysicalfilesi.e.datafiles(storesdataintables),redologfiles(stores
SQLstatementsthatcauseachangetodata),parameterfiles(storesdatabase
parameters),controlfiles(storesinformationaboutthedatabase),etc.
✓ Inaddition,thedatabasealsohaslogicalstoragei.e.tablespace,segments,extentsand
blocks.(Weshalllookatalltheselater.)
Oracle Architecture – Summary
✓ Userprocessinitiatesandmaintainsuserconnectiontotheinstance.
✓ Serverprocessinteractwiththedatabaseonbehalfoftheuser.
✓ Instanceismadeofmemorystructuresandbackgroundprocesses.
✓ Memorystructuresare:SGA(databasebuffer,redologbufferandsharedpool),PGA.
✓ Backgroundprocessesincludemandatory(SMON,PMON,DBWn,CKPT,LGWR)and
optional.
✓ Databasephysicalstoragestructuresincluderedologfile,datafile,controlfile,etc.
✓ Databaselogicalstoragestructuresincludetablespace,segments,extentsandblocks.
Preparing Oracle Environment
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
Installing Oracle Database
✓ Reviewdocumentation
✓ Harddiskspace– 200MB
✓ RAMspace- 1GB
✓ Editioni.e.Expressedition,Enterpriseedition,Standardedition.
✓ Softwareversioni.e.11g,12c,18c,21c.
✓ OUI(OracleUniversalInstaller)
Creating Oracle Database
✓ WeusetheDatabaseConfigurationAssistant(DBCA)tool
✓ Letsgetstarted
Managing Storage Structures
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
Physical Files – Control File
✓ Control file – stores important information about the database.
✓ Such information includes database name, location of the database, location and name
of database files, checkpoint information, etc.
✓ This information is so crucial and used during database startup process and during
recovery process.
✓ Because of the sensitivity of this file, it needs to be multiplexed always.
✓ It works with the DBWn and CKPT process
Physical Files – Redo Log file
✓ Redologfile– storesSQLstatementsthatcauseachangetodatapermanently.
✓ Theyarestoredinredologgroupsandeachgroupmusthaveatleastoneredologfile.
✓ Aminimumoftworedologgroupsandworkwith
✓ TheLGWRwritesonthisfileinacircularfashion.
✓ Wheneverdataismovedfromthisfile,wegetanotherfilecalledthearchivedredolog
file.
Physical Files – Data File.
✓ Datafiles– storesdataintablespermanently.
✓ Theyarestoredinalogicalstoragespacecalledthetablespace.Eachdatafilemust
belongtoonlyonetablespace.
✓ ItworkswiththeDBWnandCKPTprocess
✓ Letsseehowwecancreatetablespaceswithdatafiles.
✓ Otherfilesinclude:Parameterfiles(SPandPfiles)– storedatabaseparameterse.g.
memorytarget,controlfileparameters,etc.,archivedredologfiles,alertlogfiles,etc.
Logical Storage - Tablespace
✓ Tablespace– storedatafileslogically.
✓ Eachdatafilebelongstoonlyandonlyonetablespace.
✓ Tablespacesareusedtoorganizedataandmakebackupprocesseasier.
✓ Wehavedefaulttablespacese.g.SYSTEM– storesdatadictionary,SYSAUX– workswith
SYSTEMtablespace,USERS– storesuserobjectsanddata,etc.
✓ Wecanalsocreateourowntablespaces.
Logical Storage - Tablespace
✓ Segments – collection of extents.
✓ Extents – collection of blocks.
✓ Blocks – smallest storage unit in Oracle database.
✓ Lets see this practically.
Instance Management
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
Instance Startup Process
✓ WeusetheSTARTUPcommandtostarttheinstance
✓ YouhavetobeaDBAtostartuporshutdowntheinstance.
✓ ThefirststageofstartupprocessistheNomount stage.Hereinitializationparameters
areloaded.
✓ ThesecondstageistheMount stage– controlfileisread&instanceisassociatedwith
database.
✓ ThefinalstageistheOpen stage– alldatabasefilesarereadanddatabaseisopen.
Instance Startup Modes
✓ Differentwaysofstartinguptheinstance.
✓ StartupOpen– thisisthedefaultmode.Itisthenormalstartupprocess.
✓ StartupNomount – theinstanceisopenedupto thenomount stage.
✓ StartupMount– theinstanceisopenedupto themountstage.
✓ StartupRestrict– thedatabaseisopenedtoonlythosewithrestrictedsessionprivilege.
✓ StartupReadOnly– thedatabaseisopenedbutnoeditscanbemade.
✓ StartupForce– thedatabaseisforcedtostartup.
Instance Shutdown Process
✓ We use the SHUTDOWN command to shutdown the database
✓ You have to be a DBA to startup or shutdown the instance.
✓ The first stage of shutdown process is the Close stage. The database is shutdown and no
longer available to anyone.
✓ The second stage is the Unmount stage – the instance is de-associated with database.
✓ The final stage is the Shutdown stage – the instance is shutdown – background
processes and memory are stopped and de-allocated.
Instance Shutdown Modes
✓ Differentwaysofshuttingdowntheinstance.
✓ ShutdownNormal– thisisthedefaultmode.Itisthenormalshutdownprocess.
✓ ShutdownTransactional– Waitsforuserswithtransactions.
✓ ShutdownImmediate– Databaseisshutdownimmediately.Uncommittedtransactions
arerolledback.Noneedforrecovery.
✓ ShutdownAbort– databaseisshutdowninstantly.Uncommittedtransactionsarenot
rolledback.Itneedsrecovery.
Oracle Meta Data
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
Meta Data
✓ Metadataisdataaboutthedatabase
✓ Wemayneedtoknowthedifferentthingsaboutadatabaselikedatabaseuser
properties,therunningprocesses,thelocationofvariousfiles,alltablesinthedatabase,
etc.
✓ Oracleprovidesthisinformationtousinformofviewsi.e.virtualtables.
✓ Theseviewsaredatadictionaryviewsanddynamicperformanceviews.
✓ TheyarereallysomuchimportantinyourworkasaDBA.
Meta Data – Data Dictionary Views
✓ These provide information about the database and its objects e.g. users, tables, etc.
✓ They start with DBA_ , ALL_ , USER_
✓ DBA_ returns all specified objects in the database e.g. DBA_TABLES returns all tables
✓ ALL_ returns all objects belonging to a particular user plus those they have access to e.g.
ALL_TABLES will return all tables belonging to a user and those they have access to.
✓ USER_ returns only objects belonging to a user e.g. USER_TABLES
✓ Data dictionary views are always in plural format.
Meta Data – Dynamic Performance Views
✓ Theseprovideinformationaboutdatabasestatusandperformance.
✓ Theystartwithv$andarealwaysinsingular.
✓ Examplesincludev$process,v$logfile,v$datafile,v$sgainfo,etc.
User Security - Authentication
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
User Security – Authentication
✓ Weneedtoauthenticateuserstouseourdatabase
✓ Userauthenticationlooksatensuringtherightusersconnecttoourdatabase.
✓ Wecreateuseraccountsforintendedusersandassignresourcestothem.
✓ WehavedefaultadministrativeuseraccountsinOraclei.e.SYS,SYSTEM,SYSMAN
✓ Wealsohaveotherdefaultaccountse.g.PUBLIC,hr,etc.
✓ Tocreateauseraccount,wemustpayattentiontosomethings.
User Security – Components of User Account.
✓ A username – itshouldn’texceed30charactersandshouldn’tincludespecialcharacters.
✓ Authentication method i.e.
✓ Password authentication – database authenticates users.
✓ External authentication – operating system authenticates users.
✓ Global authentication – authentication is done by advanced sectuiry options like biometricst
✓ Default tablespace – used to store user data in case no tablespace is specified
✓ Temporary tablespace – used to store temporary segments from sorting operations
User Security – Components of User Account.
✓ Temporarytablespace– usedtostoretemporarysegmentsfromsortingoperations
✓ Quota– spaceallocatedtoauseronadefaulttablespace
✓ Profile– limitsresourceusagelikememoryusage,sessiontimeout,passwordcomplexity,
etc.
✓ Accountstatus– accountcanbeopen,locked,orexpired.
User Security - Authorization
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
User Security – Authorization
✓ Thislooksatgivingrightsorprivilegestoauseraccounttoaccessdatabaseresources.
✓ TheyareassignedusingGRANTandremovedusingREVOKE
✓ WehavedifferenttypesofprivilegesinOraclei.e.objectprivileges,systemprivileges,and
role.
✓ Objectprivileges– allowaccessandtootherusers’objectsliketablese.g.UPDATE,DELETE,INSERT,etc.
WecangivearighttothegranteetoextendthesameprivilegesgiventoanotheruserusingWITH
GRANTOPTION.Incaseofarevoke,alluserslosetherights.
✓ Systemprivileges– allowperformingofdatabaseleveloperationse.g.CREATEUSER,CREATETABLE,
ALTERTABLE,etc..Wecangivearighttothegranteetoextendthesameprivilegesgiventoanother
userusingWITHADMINOPTION.Incaseofarevoke,otherusersdonotlosetherights.
User Security – Authorization
✓ Role privileges – role is a set of privileges that can be granted to any user account in the database.
Roles can be inherited.
✓ Oracle comes with default roles for example, SYSDBA, CONNECT, RESOURCE.
✓ We can grant privileges which wish all users to have to user PUBLIC
✓ We have the principle of least privileges that encourages granting of minimum privileges
to users as much as possible.
✓ Give users only privileges they need to perform their tasks.
User Security - Auditing
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
User Security – Auditing
✓ Wefocusonkeepingtrackofalluseractionsastheyareusingthedatabase.
✓ WeenableauditingbyuseofAUDITkeywordanddisableitbyuseofNOAUDIT.
✓ Therearetypesofauditingwecanusei.e.objectauditing,privilegeauditingand
statementauditing.
✓ Wecanauditalluseractionsspecified,auditonlysuccessfulactionsusingWHENEVER
SUCCESSFULorauditonlyunsuccessfulactionsusingWHENEVERNOTSUCCESSFUL.
✓ ObjectauditingfocusesontrackingSQLstatementsthatuseobjectprivilegese.g.
UPDATE,INSERT,etc.Thisauditingcanbeenabledordisabledforallusers.
User Security – Auditing
✓ PrivilegeauditingfocusesontrackingSQLstatementsthatusesystemprivilegese.g.CREATE
TABLE,CREATEUSERetc.
✓ Privilegeauditingcanbedoneonspecificindividualsratherthanallusers.
✓ StatementauditingfocusesonmonitoringuseofspecificSQLstatements.
✓ OraclegroupsdifferentSQLstatementsintoonee.g.TABLEforCREATETABLE,ALTERTABLE,
TRUNCATETABLE,USERforCREATEUSER,ALTERUSER,DROPUSER,etc.
✓ Weusethewordgroupingtofosterauditing.Forexample,AUDITTABLE.
✓ Audittrailsarealwayskeptinoperatingsystemordatabase.Youneedtofirstconfigurethe
audittrailparameterbeforestartingtheauditing.
Database Backup
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
Database Backup
✓ Backupsimplylooksatmakingcopiesofthedatabasefilessuchthatincaseofany
failure,weeasilygetbacktonormal.
✓ Thereareseveralreasonsastowhyweshouldalwaysperformdatabasebackup.
✓ Wehavebackupstrategiesi.e.whole(alldatafilesand1controlfilearebackedup)and
partialbackup(somedatafilesarebackedupandcontrolfilebackupisoptional).
✓ Wealsohavebackuptypesi.e.full(alldataondatafilesisbackedup)andincremental
backup(onlychangeddatablocksarebackedup).
✓ Youcanbackupthedatabasewhenitisavailabletousers(hotbackup)orwhenitisnot
available(coldbackup).Thisisreferredtoasbackupmodes.
Database Backup – Recovery Components
✓ Thesehelpusinthebackupandrecoveryoperations.Theyincludethefollowing.
✓ Controlfile
✓ Redologfiles
✓ Archivedredologfiles
✓ Checkpoint
✓ FlashRecoveryArea
✓ WecanusetheRMANtoolstohelpindatabasebackup.
✓ Wefirstputthedatabaseinarchivelog modei.e.enablearchivingprocess.
Database Recovery
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com
Database Recovery – Database Failures
✓ Instance failure – happens when the SCN in the data file headers is not matching the one
in the control file.
✓ Statement failure – comes as a result of a failure of a SQL statement.
✓ User process failure – happens when there is an abrupt disconnection of the user process
from the instance.
✓ Network failure – emanates from failure of a network component or infrastructure e.g.
server, network card.
✓ User error – happens when there is deliberate or unintentional actions on data e.g.
Delete data, modifying data, etc.
Database Recovery – Database Failures
✓ Usererror– happenswhenthereisdeliberateorunintentionalactionsondatae.g.
Deletedata,modifyingdata,etc.Flashbackqueriesandflashbacktablescanhelp.
✓ Mediafailure– happenswhenthereisalossofoneofthedatabasefilesi.e.datafile,
controlfileandredologfile.TheRMANcanhelpusinrecoveringdatahere.
Thank You!
ORACLE DATABASE ESSENTIALS – MUTEBI BASHIR
www.bmutebi.com