Professional Documents
Culture Documents
Oracle DBA
Oracle DBA
TRAINING
05/01/2012
TABLE OF CONTENTS
1. Oracle Architecture
Oracle database and instance
Archive log mode in Oracle
Oracle Storage structures
2. Parameter files (spfile and pfile)
3. Dictionary views
4. Other Important DBA Queries .
5. Shutdown options in Oracle.
6. Basic Unix Commands for DBA.
7.Oracle Shared Server Vs Dedicated Server Architecture.
Domain : Life Sciences and Health Care.
Author : Alamuru Prasadu Reddy.
Mail id : alamuru.prasadureddy@tcs.com
TCS Public
ORACLE ARCHITECTURE
ORACLE DATABASE AND INSTANCE
The database is the set of files stored on disk where as Instance
(SGA+ PGA+ Process) is the collection of oracle background
processes and memory. An instance can mount and open one and
only one database whereas database can be mounted and opened by
one or more instances.
Multiple instances can run concurrently on the same computer,
each accessing its own physical database. In large-scale cluster
systems, Oracle Real Application Clusters enables multiple
instances to mount a single database.
Internal Use
BACKGROUND PROCESSES :
Following are the 5 mandatory Background processes :
Data Base Writer Process (DBWn):
Database Writer writes from database buffer cache to datafile.
Database Writer writes the dirty buffer (modified) and cold
buffer (which are not recently used) to the datafile.
Database writer writes contents to the datafile when,
Server process is not able to find the free buffers after
searching a threshold No. of dirty buffers.
DBWn periodically writes buffer to advance the checkpoint,
which is the position in the redo log from where the instance
recovery begins.
Log Writer Process (LGWR):
It is responsible for writing the contents of Redo log buffer to a
redo log file on the disk. Redo is nothing but the information of
changes made to the database.
LGWR writes one contiguous portion of the buffer to disk. LGWR
writes:
A commit record when a user process commits a transaction.
Redo log buffers
o Every three seconds.
o When the redo log buffer is one-third full.
o When a DBWn process writes modified buffers to disk.
Internal Use
Internal Use
Internal Use
Internal Use
Internal Use
Internal Use
Internal Use
Database Block :
The smallest unit of allocation in an Oracle database. One or more
database blocks compose a database extent.
Every database block in a table space has the same number of
bytes.
The different table spaces within a database can have database
blocks with different sizes.
Typically, one or more rows of a table will reside in a database
block, although very long rows may span several database blocks.
A database block can have a size of 2KB, 4KB, 8KB, 16KB, or
32KB. Once any table space, including the SYSTEM and
SYSAUX table spaces, is created with a given block size, it cannot
be changed.
Data Block :
The header contains general block information, such as the block
address and the type of segment (for example, data or index).
Table directory portion of the data block contains information
about the table having rows in this block.
Row Directory contains information about the actual rows in the
block .The data block header, table directory, and row directory are
referred to collectively as overhead.
Internal Use
10
Internal Use
11
Internal Use
12
Internal Use
13
Internal Use
14
PARAMETER FILES
There are two types of parameter files in Oracle.
PFILE:
Password File :
The Oracle Password File stores passwords for users with
administrative privileges. One needs to create a password files
before remote administrators (like OEM) will be allowed to
connect.
Default location is $ORCALE_HOME/ database in
windows and $ORCALE_HOME/dbs in UNIX.
Using password file give an extended level of authentication.
Using password file we can add the users Whom we want to
grant the login rights.
Internal Use
15
Internal Use
16
DICTIONARY VIEWS
List of some important Data Dictionary Views in Oracle.
DBA_DATA_FILES: DBA_DATA_FILES view gives the information
about data file details.
DBA_TABLESPACES: This View gives information about all
Table spaces in the database.
DBA_FREE_SPACE: This View gives information about the free
extents in all table spaces in the database.
DBA_USERS: This View gives information about all users of the
database.
DBA_OBJECTS: This View gives information about all objects in the
database.
DBA_SEGMENTS: This View gives information about the storage
allocated for all segments in the database.
DICT: DICT is the synonym for Dictionary; it contains the descriptions
of data dictionary tables and views.
DBA_INDEXES: DBA_INDEXES describes all indexes in the database.
DBA_IND_COLUMNS: DBA_IND_COLUMNS describes the columns
of all the indexes on all tables and clusters in
the database.
ALL_SOURCE: ALL_SOURCE describes the text source of the stored
objects accessible to the current user.
Internal Use
17
V$session: This view lists session information for each current session
Session is identified uniquely using Sid, serial#
V$locked_Objects: This view lists locks acquired by every transaction
on the system.
V$sqlarea: V$SQLAREA lists statistics on shared SQL area and
contains one row per SQL string. It provides statistics on
SQL statements that are in memory, parsed, and ready for
execution.
V$sysstat: This view lists system statistics.
V$sessstat: This view lists user session statistics.
Internal Use
18
Internal Use
19
Internal Use
20
Internal Use
21
Internal Use
22
3. Shutdown Abort
During shutdown abort, before the oracle database is shutdown, all user
sessions will be terminated immediately. Un committed transactions will
not be rolled back. Use this option only during emergency situations
when the shutdown and shutdown immediate doesnt work.
$ sqlplus '/ as sysdba'
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Jan 18 11:11:33 2009
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to an idle instance.
Internal Use
23
Command
Example
cat
cat myfile
append to a file
cat
cat
create a file
cat
cat >newfile
copy a file
cp
cp myfile newfile
create a file
touch
touch newfile
move a file
mv
mv myfile /usr/home/myfile
remove a file
rm
rm myfile
Command
change directory
cd
cd
cd
mkdir
rmdir
pwd
ls
ls
ls
ls
du
Internal Use
Example
cd
$ORACLE_HOME
cd ..
cd
mkdir mydir
rmdir mydir
pwd
ls
ls -l
ls -al
ls-lrt
du -k mydir
24
Miscellaneous
Action
change password
list processes -owner
list processes -everyone
list processes -username
show process for sid
show smon processes
Command
passwd
ps
ps
ps
ps
ps
/usr/ucb/ps show full process path
augxwv
change access privileges
chmod
read/write -owner,group
chmod
read/write/execute- owner,group chmod
read -owner,group,world
chmod
execute -owner,group
chmod
change ownership
chown
default security for new files
umask
change group
newgrp
who else is logged on
who
who owns this session
who
what is my session and group
id
quick top and uptime
w
Internal Use
Example
passwd
ps
ps -e
ps -fu username
ps -ef|grep [sid]
ps -ef|grep smon
chmod XXX
chmod 660 myfile
chmod 770 myfile
chmod 444 myfile
chmod 110 myfile
see access modes
umask 023
newgrp dba
who
who am i
id
w
25
Internal Use
26
Internal Use
27
Internal Use
28