Database Notes
Database Notes
(1) Creates and maintains all databases required for development, testing, education and
production usage.
(2) Performs the capacity planning required to create and maintain the databases. The DBA
works closely with system administration staff because computers often have applications or
tools on them in addition to the Oracle Databases.
(4) Install new versions of the Oracle RDBMS and its tools and any other tools that access the
Oracle database.
(5) Plans and implements backup and recovery of the Oracle database.
(6) Controls migrations of programs, database changes, reference data changes and menu
changes through the development life cycle.
(7) Implements and enforces security for all of the Oracle Databases.
(8) Performs database re-organisations as required to assist performance and ensure maximum
uptime of the database.
(9) Puts standards in place to ensure that all application design and code is produced with proper
integrity, security and performance. The DBA will perform reviews on the design and code
frequently to ensure the site standards are being adhered to.
(10) Evaluates releases of Oracle and its tools, and third party products to ensure that the site is
running the products that are most appropriate.
Planning is also performed by the DBA, along with the application developers and System
administrators, to ensure that any new product usage or release upgrade takes place with minimal
impact.
(11) Provides technical support to application development teams. This is usually in the form of
a help desk. The DBA is usually the point of contact for Oracle Corporation.
(12) Enforces and maintains database contraints to ensure integrity of the database.
(13) Administers all database objects, including tables, clusters, indexes, views, sequences,
packages and procedures.
(14) Assists with impact analysis of any changes made to the database objects.
(15) Troubleshoots with problems regarding the databases, applications and development tools.
(18) The DBA has ultimate responsibility for the physical database design.
(3) Ability to perform both Oracle and also operating system performance monitoring and the
necessary adjustments.
(10) Experience and knowledge in migrating code, database changes, data and menus through
the various stages of the development life cycle.
(12) A sound knowledge of both database and program code performance tuning.
(14) A DBA should have sound communication skills with management, development teams,
vendors, systems administrators and other related service providers.
Oracle database server: An Oracle server includes an Oracle Instance and an Oracle
database.
An Oracle database includes several different types of files: datafiles, control files, redo log
files and archive redo log files. The Oracle server also accesses parameter files and password
files.
Oracle instance: An Oracle Instance consists of two different sets of components:
The first component set is the set of background processes (PMON, SMON, RECO, DBW0,
LGWR, CKPT, D000 and others).
o each background process is a computer program.
o These processes perform input/output and monitor other Oracle processes to provide good
performance and database reliability.
The second component set includes the memory structures that comprise the Oracle instance.
o When an instance starts up, a memory structure called the System Global Area (SGA) is
allocated.
o At this point the background processes also start.
An Oracle Instance provides access to one and only one Oracle database.
Oracle database: An Oracle database consists of files. Sometimes these are referred to as
operating system files, but they are actually database files that store the database information
that a firm or organization needs in order to operate.
The redo log files are used to recover the database in the event of application program
failures, instance failures and other minor failures.
The archived redo log files are used to recover the database if a disk fails.
Other files not shown in the figure include:
User and server processes: The processes shown in the figure are
called user and server processes. These processes are used to manage the execution of SQL
statements.
A Shared Server Process can share memory and variable processing for multiple user
processes.
A Dedicated Server Process manages memory and variables for a single user process.
Oracle database server: An Oracle server includes an Oracle Instance and an Oracle
database.
An Oracle database includes several different types of files: datafiles, control files, redo log
files and archive redo log files. The Oracle server also accesses parameter files and password
files.
Oracle instance: An Oracle Instance consists of two different sets of components:
The first component set is the set of background processes (PMON, SMON, RECO, DBW0,
LGWR, CKPT, D000 and others). Each background process is a computer program. These
processes perform input/output and monitor other Oracle processes to provide good performance
and database reliability.
The second component set includes the memory structures that comprise the Oracle
instance. When an instance starts up, a memory structure called the System Global Area (SGA)
is allocated.
Oracle database: An Oracle database consists of files. Sometimes these are referred to as
operating system files, but they are actually database files that store the database information .
The redo log files are used to recover the database in the event of application program
failures, instance failures and other minor failures.
The archived redo log files are used to recover the database if a disk fails.
Other files not shown in the figure include:
The required parameter file that is used to specify parameters for configuring an Oracle
instance when it starts up.
The optional password file authenticates special users of the database – these are
termed privileged users and include database administrators.
Alert and Trace Log Files – these files store information about errors and actions taken
that affect the configuration of the database.
The SGA is a read/write memory area that stores information shared by all database processes
and by all users of the database (sometimes it is called the Shared Global Area).
o This information includes both organizational data and control information used by the
Oracle Server.
o The SGA is allocated in memory and virtual memory.
o The size of the SGA can be established by a DBA .
Shared Server (One genie- Many Masters): where more than one User Process shares a pool
of Server Process. Oracle manages this by means of a network process called dispatcher, which
The undo segment is a database object in Oracle that stores old versions of data being changed
by DML statements issued by the user process. It stores only the old value and not the new
values (new values stored in object itself).
Oracle 9i is a large application that comes on three CD’s and required 1GB space. In unix
systems we need mount and unmount your CD-ROM repeatedly.
Example:
mount –r –v cdrfs /dev/cd0/cdrom
The following steps are to be followed in to unmount the CD-ROM
1. Change directory to the root directory of your system and log in as the root user by using
the following commands:
$ cd /
$ su root
2. Unmount and remove the CD-ROM from the CD-ROM
3. Insert and mount the next CD-ROM into the CD-ROM drive
4. Enter the mount command
5. Enter the correct mount point in the Installation dialog box (OUI) .Click OK to
continue. On starting the OUI, the following occurs.
You will be prompted whether you want to install the Enterprise or Standard edition of
the Software or custom install the software.
You will then be prompted whether you want to install just the software or have a general
installation.
You will be asked questions related to software installation location, if you choose to
create a database, the name of the database and location for the database files.
If you have chosen custom installation option, you will have to select the components
(including OUI).
The database configuration assistance will be invoked to assist in creating the database.
OUI creates oraInventory directory for the first time it is run to keep an inventory of the products
installed.
instllationActions.log→ stores the log of recent installations.
Non-interactive installation
Non interactive installation is possible by supplying OUI with a response file. OUI uses
information in the response file to provide answers to the installer prompts.
SYS, SYSTEMS are two users Oracle creates when installing the database, each having own
default password. The default password for SYS = change_on_install; for SYSTEMS=manager.
SYS is more important than SYSTEMS.
Disadvantages:
i. You must have a machine login to use Oracle.
ii.To use this method, a special group called dba must be created on the OS before you install
oracle s/w.
Authentication with a password file
The DBA creates the password file, and passwords for all others permitted to administer Oracle
are stored in the file. The password file is created with ORAPWD utility. In both Unix and
Windows, we use orapwd.
While using ORAPWD, we pass three parameters: FILE, PASSWORD and
ENTRIES FILE-> we usually place the password file in $ORACLE_HOME/dbs
PASSWORD→ you define the password for your password
file ENTRIES→ number of entries allowed for a password file.
Example
D:\Oracle\Bin\>orapwd File=D:\Oracle\dbs\orapwd1.pwd
PASSWORD= srm ENTRIES=5
OEM Architecture
OEM is a three tier model.
The first tier contains java based console and integrated applications that can be
installed or run from a web browser.
The SQL Worksheet allows you to enter, edit, and execute SQL and PL/SQL code. You can also
execute the Server Manager DBA commands .You can also run scripts from the SQL Worksheet.
The SQL Worksheet maintains a history of the commands you have issued, so you can easily
retrieve and re-execute previous commands.
You can start a SQL Worksheet from the Enterprise Manager Console window by choosing SQL
Worksheet from the Tools menu. The new worksheet is connected to the database you have
selected in the Navigator tree list or in the Map window.
If you start the SQL Worksheet from the Windows Program Manager, a database Login dialog
box appears.
Using OEM
We can administer every aspect of Oracle using OEM. In OEM we can see that all database tools
or managers are available in a tree fashion.
The instance manager allows you to administer the instance like starting and shutting the
database.
Schema manager permits you to administer database objects like tables and indexes.
Security manager allows to administer the users, roles and profiles.
Storage manager allows you to administer tablespaces, rollback segments and redo logs.
Oracle database is a set of tables, indexes and procedures and other objects used for storing
data. It is identified by the database name DB_NAME. A database instance is a set of memory
structures that manage database files. A database is created by the CREATE DATABASE
statement.
Oracle Instance is the memory structures, background processes and disk resources. To start the
instance, the steps given are carried out. The instance manages its associated data and serves the
users of the database.
A database instance (Server) is a set of memory structure and background processes that access
a set of database files. The process can be shared by all users. The memory structure that are
used to store most queried data from database.
Normal database operation means that an instance is started and the database is mounted and open. This
mode allows any valid user to connect to the database and perform data access operations.
Options for starting Oracle
There are several options available for starting Oracle instances: with or without mounting
the database.
startup nomount
Start the instance without mounting a database. This does not allow access to the database and
usually would be done only for database creation or the re-creation of control files. All memory
structures and background processes are in place, but no database is attached. This option with or
without specifying an initsid.ora file for the PFILE parameter. This options of starting Oracle
without mounting the database includes the following tasks
reading parameter file init.ora
startup mount
This option starts the instance, reads the control file and attaches the database, but it does not open it.
Start the instance and mount the database, but leave it closed. This state allows for certain DBA activities, but
does not allow general access to the database. You can start an instance and mount a database without opening
it, allowing you to perform specific maintenance operations.
This option is used in situations where you have to move physical database files or when database recovery.
Options of starting Oracle with mounting the database includes the following tasks
associating database with a previously started instance
opening control files
reading control files
startup open
This option starts your instance, attaches the database and opens it. This is the default option for
starting Oracle.
Start the instance, and mount and open the database. This can be done in unrestricted mode,
allowing access to all users, or in restricted mode, allowing access for database administrators
only.
startup force
This option forces the instance to start and the database to open.It is used in situations where
other startup options are met with errors from Oracle and no shutdown options seem to work.
Two other options for database startup are
1. startup recover : for handling database recovery
2. startup restrict: for opening the database while simultaneously preventing all users but the DBA
from accessing database objects.
Starting the database automatically
Most DBAs’ want their database to start automatically whenever the host machine is rebooted. Many sites use
procedures to enable automatic startup of one or more Oracle Database instances and databases immediately
following a system start. The procedures for performing this task are specific to each operating system.
Shutting down the Oracle instance is same as starting the Oracle instance. You should have
logged with sysdba privileges. From SQL* Plus do the following
example:
This is the lowest priority shutdown.Normal database shutdown proceeds with the following conditions:
SQL>SHUTDOWN NORMAL
Database closed
Database Dismounted
Oracle instance shut down
This is the higher priority shut down the DBA can use. When this mode of shut down is opted, the
following things will happen.
No new connections are allowed, nor are new transactions allowed to be started, after the
statement is issued.
Current client SQL statements being processed by Oracle Database are immediately terminated.
When you want to perform a planned shutdown of an instance while allowing active transactions to
complete first
SQL>SHUTDOWN transactional
Database closed
Database Dismounted
No new connections are allowed, nor are new transactions allowed to be started, after the statement
is issued.
After all transactions have completed, any client still connected to the instance is disconnected.
At this point, the instance shuts down just as it would when a SHUTDOWN IMMEDIATE statement
is submitted.
--------------------------------------------------------------------
The act of creating a database is nothing but the creation of a physical database. Before creating
the database, ERD , which shows the relationship between tables and the columns is created,
DBA translates this logical design (ERD) into a physical design. The database can be created
using
Make sure your machine has the capacity to handle Oracle: You have to ensure that
the host machine has the CPU power , memory and disk space it takes to run an Oracle
database in a multiuser environment.
Ensure that you have at least three separately controlled disk resources: Oracle
recommends three separately controlled disk resources. A running Oracle database has
many moving parts, all these parts are moving at the same time.
Configure certain environmental settings: The following environment variables are to
be configured. ORACLE_BASE, ORACLE_HOME, ORACLE_SID.
Shut down and back up other Oracle databases running on the host : If the system
already contains other databases, then shut down and save a backup of these and then
install
Install Oracle recommended operating system patches on the machine: The exact
operating system version and patches differ from one OS to the other.
2. DB_DOMAIN: Identifies the domain location of the database name within a network–
this parameter is used in a distributed database system. DB_DOMAIN specifies the logical
location of the database within the network structure.
3. DB_BLOCK_SIZE – specifies the size of the default Oracle block in the database. .
This is also called as standard block size. This parameter cannot be changed once the database is
created.
4. CONTROL_FILES – This is a name or list of names for the control files of the
database- it tells Oracle the location of the control files to be read during database startup and
operation. The control files are typically multiplexed (multiple copies).
5. DB_CACHE_SIZE – specifies the size of the area the SGA allocates to hold blocks of
the default size. If the parameter is not specified, then the default is 0 . If the parameter is
specified, then the user-specified value indicates a minimum value for the memory pool.
6. LOG_BUFFER: This is the size of redo log buffer in bytes.
7. UNDO_MANAGEMENT: Initialization parameter determines whether the Oracle
server automatically or the DBA manually handles undo data.
8. UNDO_TABLESPACE: Parameter set to the name of the table space you want to use to
house undo segments generated and managed automatically by Oracle
9. PROCESSES: This is the number of processes that can connect to Oracle at any given
time.
Oracle database: An Oracle database consists of files. Sometimes these are referred to as
operating system files, but they are actually database files that store the database information
that a firm or organization needs in order to operate.
The SGA is a read/write memory area that stores information shared by all database
processes and by all users of the database (sometimes it is called the Shared Global
Area).
o This information includes both organizational data and control information used by
the Oracle Server.
o The size of the SGA can be established by a DBA by assigning a value to the
parameter SGA_MAX_SIZE in the parameter file—this is an optional parameter.
4. Explain the purpose of the following: Buffer Cache, Redo Log Buffer, Shared Pool
Buffer Cache – contains buffers, each size of a database block that stores data needed by SQL.
The buffers are of equal size. The size of the buffer is indicated in a parameter file
Redo Log Buffer-- temporarily stores in memory the redo entry information generated by
DML statements (Update, delete, insert) run in user sessions until Oracle writes the
information into the disk.
Shared Pool – includes two components:
o Library Cache –used for storing SQL statement text and the statements execution
plan for reuse.
o Data Dictionary Cache –also called as row cache, used for storing recently accesses
information from the Oracle data dictionary like tables, columns, usernames,
passwords…
5. What is a PGA?
6. What are the two ways by which DBA’s can set up Oracle to run server processes?
There are two ways DBA’s can set up Oracle to run server processes:
Dedicated Server connection (One genie-One Master): a one-to-one correspondence between
the User and Server Processes. Every user connecting to Oracle will have a personal genie
handling data retrieval from disk into buffer cache. Each user get his data retrieval requests acted
upon immediately.
Shared Server connection :(One genie- Many Masters): where more than one User Process
shares a pool of Server Process. Oracle manages this by means of a network process called
dispatcher, which puts the user requests for data into one queue and shared server process fulfill
all the requests one at a time. This reduces memory and CPU burden.
There are several ways to process an Oracle select statement. The operations involved in both
select and DML statement is shown in diagram. The select statement processing flow is
The undo segment is a database object in Oracle that stores old versions of data being changed
by DML statements issued by the user process. It stores only the old value and not the new
values (new values stored in object itself).
1. Parse statement:
2. Execute Statement:
3. Generate Redo information:
Issuing a commit statement ends the current transaction by making any data change the user
process may have issued to the Oracle database permanent.
A rollback discards the data changes.
By keeping a copy of old data in the undo segment, oracle discards any changes made by the
transaction until the commit statement is issued.
1. Release table/ row locks acquired by transaction:
2. Release undo segment locks acquired by transaction:
3. Generate redo committed transaction:
OUI features
The look and feel of OUI is nice and you can obtain help with installing your Oracle
software. The new capability includes installing Oracle database software, client software
and integration software.
OUI not only installs the database software , but also provides an option to create
different types of databases using configuration assistants.
It accepts automated software installation.
It tracks its own activities with a log file, showing the activities of the OUI and packager.
12. State the approaches are available for secure the authentication
SYS, SYSTEMS are two users Oracle creates when installing the database, each having own
default password. The default password for SYS = change_on_install; for SYSTEMS=manager.
SYS is more important than SYSTEMS.
15. Explains the list of applications available for OEM, along with description and use.
17. Define: Oracle instance, Oracle Database. What is the normal database operation?
Oracle database is a set of tables, indexes and procedures and other objects used for storing
data. It is identified by the database name DB_NAME.
Oracle Instance is the memory structures, background processes and disk resources.
To start the instance, the steps given are carried out.
1. Start SQL* plus and login as sysdba.
2. From SQL* plus, use the start_option [dbname] to start the instance.
A database instance is a set of memory structures that manage database files. A database is a
set of physical files on disk created by the CREATE DATABASE statement. The instance
manages its associated data and serves the users of the database. A database instance (Server) is
a set of memory structure and background processes that access a set of database files. The
process can be shared by all users. The memory structure that are used to store most
queried data from database.
Normal database operation means that an instance is started and the database is mounted and open.
This mode allows any valid user to connect to the database and perform data access operations.
startup nomount
startup mount
startup open
startup force
There are several modes for shutting down a database: normal, immediate, transactional, and abort.
Shutting Down with the Normal Mode
Shutting Down with the Immediate Mode
Shutting Down with the Transactional Mode
Shutting Down with the Abort Mode
********************