Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Oracle-9: Unit - 9 (A) One Mark Questions

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 12

Oracle-9

UNIT – 9

( A ) One mark questions.

1. CKPT background process stands for ______.


Checkpoint
2. SMON background process stands for ______.
System Monitor
3. PMON background process stands for ______.
Process Monitor
4. ARC background process stands for ______.
Archiver
5. LMS background process stands for ______.
Lock Manager Server
6. QMN background process stands for ______.
Queue Monitor
7. LGWR background process stands for ______.
Log Writer (LGWR)
8. DBW background process stands for ______.
Database Writer
9. SGA stands for _________.
System Global Area
10. PGA stands for _________.
Program Global Area

( B ) Two marks questions.

1. Discuss Database Startup in brief.

The database is open and ready for use after being created. Once the operating
system is shut down, or the database is shut down, it must be started before it can
be accessed.

STARTUP  [MOUNT or OPEN] dbname


          [NOMOUNT]
          [RECOVER]

 STARTUP OPEN dbname PFILE=filename  This command starts the instance,


and opens the database named dbname using the parameter file specified by
the filename following the PFILE= clause. This starts up the database in the
default, EXCLUSIVE mode.
 STARTUP NOMOUNT  This command starts the instance, but leaves the
database dismounted and closed. Cannot be used with EXCLUSIVE, MOUNT,
or OPEN. Normally this command is used only when creating a database.
There are some maintenance activities that require the database to be in
NOMOUNT but generally it is only used with database creation.

Gaurav k sardhara Page 1


Oracle-9

 STARTUP MOUNT  This command starts the instance and mounts the
database, but leaves it closed.

2. Discuss Database shutdown in brief.

The databases should be shut down before system shutdowns, before full backups
and any time system operations require it to be shut down.

You should alter the shutdown scripts to do a SHUTDOWN IMMEDIATE. This backs
out any uncommitted user transactions, logs them out and then shuts down the
database. If a normal SHUTDOWN is performed, the system politely waits for all
users to log off of Oracle . . . if Joe is on vacation and left his terminal up in a form,
you could have a long wait. The other shutdown, SHUTDOWN ABORT, should only be
used for emergencies as it stops the database just as it is, with operations pending or
not. A SHUTDOWN ABORT will require a recovery on startup.

To perform a manual shutdown on either system, perform the following procedure.

 No option means SHUTDOWN NORMAL.  The database waits for all users to
disconnect, prohibits new connects, then closes and dismounts the database,
then shuts down the instance.
 SHUTDOWN IMMEDIATE.  Cancels current calls like a system interrupt, and
closes and dismounts the database, then shuts down the instance. PMON
gracefully shuts down the user processes. No instance recovery is required on
startup.

 SHUTDOWN ABORT.  This doesn’t wait for anything. It shuts the database
down now. Instance recovery will probably be required on startup. You
should escalate to this by trying the other shutdowns first.

3. What is the role of SQL*Loader file in oracle.

SQL*Loader loads data from external files into tables of an Oracle database. It has a
powerful data parsing engine that puts little limitation on the format of the data in
the datafile. You can use SQL*Loader to do the following:

 Load data across a network. This means that you can run the SQL*Loader
client on a different system from the one that is running the SQL*Loader
server.
 Load data from multiple datafiles during the same load session.

 Load data into multiple tables during the same load session.

 Specify the character set of the data.


Gaurav k sardhara Page 2
Oracle-9

 Selectively load data (you can load records based on the records' values).

 Manipulate the data before loading it, using SQL functions.

 Generate unique sequential key values in specified columns.

 Use the operating system's file system to access the datafiles.

 Load data from disk, tape, or named pipe.

 Generate sophisticated error reports, which greatly aid troubleshooting.

 Load arbitrarily complex object-relational data.

 Use secondary datafiles for loading LOBs and collections.

 Use either conventional or direct path loading. While conventional path


loading is very flexible, direct path loading provides superior loading
performance. See Chapter 11.

A typical SQL*Loader session takes as input a control file, which controls the
behavior of SQL*Loader, and one or more datafiles. The output of SQL*Loader is an
Oracle database (where the data is loaded), a log file, a bad file, and potentially, a
discard file

( C ) Three marks questions.

1. Explain Oracle Database Physical Structure in detail.

An Oracle database's physical structure is determined by the operating system files


that constitute the database. Each Oracle database is comprised of these types of
files: one or more data files, two or more redo log files, and one or more control
files. The files of a database provide the actual physical storage for database
information.

Gaurav k sardhara Page 3


Oracle-9

Control Files:

A control file contains information about the associated database that is required for
access by an instance, both at startup and during normal operation. Control file
information can be modified only by Oracle; no database administrator or user can
edit a control file.

Among other things, a control file contains information such as:

 The database name


 The timestamp of database creation

 The names and locations of associated datafiles and online redo log files

 Tablespace information

 Datafile offline ranges

 The log history

 Archived log information

 Backup set and backup piece information

 Backup datafile and redo log information

 Datafile copy information

 The current log sequence number

 Checkpoint information

Redo Log Files

Gaurav k sardhara Page 4


Oracle-9

The most crucial structure for recovery operations is the online redo log, which
consists of two or more preallocated files that store all changes made to the
database as they occur. Every instance of an Oracle database has an associated
online redo log to protect the database in case of an instance failure.

Data Files

A tablespace in an Oracle database consists of one or more physical datafiles. A


datafile can be associated with only one tablespace and only one database.

Oracle creates a datafile for a tablespace by allocating the specified amount of disk
space plus the overhead required for the file header. When a datafile is created, the
operating system under which Oracle runs is responsible for clearing old information
and authorizations from a file before allocating it to Oracle. If the file is large, this
process can take a significant amount of time. The first tablespace in any database is
always the SYSTEM tablespace, so Oracle automatically allocates the first datafiles of
any database for the SYSTEM tablespace during database creation.

2. Explain CREATE DATABASE Statement with example.

To create the new database, use the CREATE DATABASE statement.

The following statement creates database mynewdb:

CREATE DATABASE mynewdb


USER SYS IDENTIFIED BY sys_pwd
USER SYSTEM IDENTIFIED BY system_pwd
LOGFILE GROUP 1 ('/vobs/oracle/oradata/mynewdb/redo01.log') SIZE 100M,
GROUP 2 ('/vobs/oracle/oradata/mynewdb/redo02.log') SIZE 100M,
GROUP 3 ('/vobs/oracle/oradata/mynewdb/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
DATAFILE '/vobs/oracle/oradata/mynewdb/system01.dbf' SIZE 325M REUSE
DEFAULT TEMPORARY TABLESPACE tempts1
DATAFILE '/vobs/oracle/oradata/mynewdb/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/vobs/oracle/oradata/mynewdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED;

Gaurav k sardhara Page 5


Oracle-9

A database is created with the following characteristics:

 The database is named mynewdb.


 Three control files are created as specified by
the CONTROL_FILES initialization parameter. 
 The password for user SYS is sys_pwd and the password
for SYSTEM is system_pwd .
 The new database has three online redo log files as specified in
the LOGFILE clause. MAXLOGFILES, MAXLOGMEMBERS,
and MAXLOGHISTORY define limits for the redo log.
 MAXDATAFILES specifies the maximum number of datafiles that can be open
in the database. This number affects the initial sizing of the control file.
 MAXINSTANCES specifies that only one instance can have this database
mounted and open.
 The SYSTEM tablespace, consisting of the operating system
 The SYSTEM tablespace is a locally managed tablespace.
 The DEFAULT_TEMPORARY_TABLESPACE clause creates and names a default
temporary tablespace for this database.
 The UNDO_TABLESPACE clause creates and names an undo tablespace to be
used to store undo records for this database if you have
specifiedUNDO_MANAGEMENT=AUTO in the initialization parameter file.
3. Explain CREATE ROLLBACK SEGMENT with example.

Use the CREATE ROLLBACK SEGMENT statement to create a rollback segment, which


is an object that Oracle uses to store data necessary to reverse, or undo, changes
made by transactions.

Further, if your database has a locally managed SYSTEM tablespace, then you cannot


create rollback segments in any dictionary-managed tablespace. Instead, you must

 Use the Automatic Undo Management feature, which uses undo tablespaces
instead of rollback segments to hold undo data, or
 Create locally managed tablespaces to hold the rollback segments.

Oracle Corporation recommends that you use Automatic Undo Management.

 A tablespace can have multiple rollback segments. Generally, multiple


rollback segments improve performance.
 The tablespace must be online for you to add a rollback segment to it.

 When you create a rollback segment, it is initially offline. To make it available


for transactions by your Oracle instance, bring it online using
the ALTER ROLLBACK SEGMENT statement. To bring it online automatically
whenever you start up the database, add the segment's name to the value of
the ROLLBACK_SEGMENTS initialization parameter.

Gaurav k sardhara Page 6


Oracle-9

To use objects in a tablespace other than the SYSTEM tablespace:

 If you are running the database in rollback undo mode, at least one rollback
segment (other than the SYSTEM rollback segment) must be online.
 If you are running the database in Automatic Undo Management mode, at
least one UNDO tablespace must be online.

CREATE ROLLBACK SEGMENT rbs_one


TABLESPACE rbs_ts
STORAGE
( INITIAL 10K
NEXT 10K
MAXEXTENTS UNLIMITED);

4. Discuss Export Utility in oracle.

The Export utility to write data from an Oracle database into an operating system file
in binary format. This file is stored outside the database, and it can be read into
another Oracle database using the Import utility. 

The Export utility provides a simple way for you to transfer data objects between
Oracle databases, even if they reside on platforms with different hardware and
software configurations.

The Export utility provides four modes of export:

 Full--Only users with the IMP_FULL_DATABASE role can import in this mode,


which imports a full database export dump file. Use the FULL parameter to
specify this mode.
 Tablespace--allows a privileged user to move a set of tablespaces from one
Oracle database to another. Use the TRANSPORT_TABLESPACE parameter to
specify this mode.
 User (Owner)--allows you to import all objects that belong to you (such as
tables, grants, indexes, and procedures). A privileged user importing in user
mode can import all objects in the schemas of a specified set of users. Use
the FROMUSER parameter to specify this mode.
 Table--allows you to import specific tables and partitions. A privileged user
can qualify the tables by specifying the schema that contains them. Use
the TABLES parameter to specify this mode.

All users can export in table mode and user mode. Users with
the EXP_FULL_DATABASE role (privileged users) can export in all modes.

Command line Syntax

exp username/password PARAMETER=value


Gaurav k sardhara Page 7
Oracle-9

For example,
exp test/test FULL=y FILE= expdat.dmp GRANTS=y INDEXES=y CONSISTENT=y

5. Discuss Import Utility in oracle.

The Import utility reads the object definitions and table data from an Export dump
file. It inserts the data objects into an Oracle database.
The Import utility provides four modes of import.
 Full
 User (Owner)
 Table
 Tablespace
All users can import in table mode and user mode. Users with the
IMP_FULL_DATABASE role (privileged users) can import in all modes.

Command line Syntax


imp username/password PARAMETER=value
For example,
imp scott/tiger FULL=y FILE=expdat.dmp INDEXES=y CONSISTENT=y

( D ) Five marks questions.

1. Explain oracle instance in brief.

An Oracle server consists of an Oracle database and an Oracle server instance. Every
time a database is started, a system global area (SGA) is allocated and Oracle
background processes are started. The combination of the background processes
and memory buffers is called an Oracle instance.

An Oracle server uses memory structures and processes to manage and access the
database. All memory structures exist in the main memory of the computers that
constitute the database system. Processes are jobs that work in the memory of these
computers.

Memory Structure and Processes Overview

An Oracle server uses memory structures and processes to manage and access the
database. All memory structures exist in the main memory of the computers that
constitute the database system. Processes are jobs that work in the memory of these
computers.

The architectural features discussed in this section enable the Oracle server to
support:

Gaurav k sardhara Page 8


Oracle-9

 Many users concurrently accessing a single database


 The high performance required by concurrent multiuser, multiapplication
database systems

2. Discuss different Database Processes in oracle.

A process is a "thread of control" or a mechanism in an operating system that can


run a series of steps. Some operating systems use the terms job or task. A process
generally has its own private memory area in which it runs.

An Oracle server has two general types of processes: user processes and Oracle
processes.

User (Client) Processes

User processes are created and maintained to run the software code of an


application program or an Oracle tool. User processes also manage communication

Gaurav k sardhara Page 9


Oracle-9

with the server process through the program interface, which is described in a later
section.

Server Processes

Oracle creates server processes to handle requests from connected user processes.


A server process communicates with the user process and interacts with Oracle to
carry out requests from the associated user process. For example, if a user queries
some data not already in the database buffers of the SGA, then the associated server
process reads the proper data blocks from the datafiles into the SGA.

Oracle can be configured to vary the number of user processes for each server
process. In a dedicated server configuration, a server process handles requests for a
single user process. A shared server configurationlets many user processes share a
small number of server processes, minimizing the number of server processes and
maximizing the use of available system resources.

On some systems, the user and server processes are separate, while on others they
are combined into a single process. If a system uses the shared server or if the user
and server processes run on different machines, then the user and server processes
must be separate. Client/server systems separate the user and server processes and
run them on different machines.

Background Processes

Oracle creates a set of background processes for each instance. The background


processes consolidate functions that would otherwise be handled by multiple Oracle
programs running for each user process. They asynchronously perform I/O and
monitor other Oracle process to provide increased parallelism for better
performance and reliability.

Each Oracle instance can use several background processes. The names of these
processes are DBWn, LGWR, CKPT, SMON, PMON, ARCn, RECO, Jnnn, Dnnn, LMS,
and QMNn.

Database Writer (DBWn)

The database writer writes modified blocks from the database buffer cache to the
datafiles. Although one database writer process (DBW0) is sufficient for most
systems, you can configure additional processes (DBW1 through DBW9 and DBWa
through DBWj) to improve write performance for a system that modifies data
heavily. The initialization parameter DB_WRITER_PROCESSES specifies the number of
DBWn processes.

Gaurav k sardhara Page 10


Oracle-9

Because Oracle uses write-ahead logging, DBWn does not need to write blocks when
a transaction commits. Instead, DBWn is designed to perform batched writes with
high efficiency. In the most common case, DBWnwrites only when more data needs
to be read into the SGA and too few database buffers are free. The least recently
used data is written to the datafiles first. DBWn also performs writes for other
functions, such as checkpointing.

Log Writer (LGWR)

The log writer writes redo log entries to disk. Redo log entries are generated in the
redo log buffer of the SGA, and LGWR writes the redo log entries sequentially into
an online redo log. If the database has a multiplexed redo log, then LGWR writes the
redo log entries to a group of online redo log files.

Checkpoint (CKPT)

At specific times, all modified database buffers in the SGA are written to the datafiles
by DBWn. This event is called a checkpoint. The checkpoint process is responsible for
signaling DBWn at checkpoints and updating all the datafiles and control files of the
database to indicate the most recent checkpoint.

System Monitor (SMON)

The system monitor performs recovery when a failed instance starts up again. With


Real Application Clusters, the SMON process of one instance can perform instance
recovery for other instances that have failed. SMON also cleans up temporary
segments that are no longer in use and recovers terminated transactions skipped
during recovery because of file-read or offline errors. These transactions are
eventually recovered by SMON when the tablespace or file is brought back online.
SMON also coalesces free extents in the dictionary managed tablespaces to make
free space contiguous and easier to allocate.

Process Monitor (PMON)

The process monitor performs process recovery when a user process fails. PMON is


responsible for cleaning up the cache and freeing resources that the process was
using. PMON also checks on dispatcher and server processes and restarts them if
they have failed.

Archiver (ARCn)

The archiver copies the online redo log files to archival storage after a log switch has
occurred. Although a single ARCn process (ARC0) is sufficient for most systems, you
can specify up to 10 ARCn processes by using the dynamic initialization
parameter LOG_ARCHIVE_MAX_PROCESSES. If the workload becomes too great for
the current number of ARCn processes, then LGWR automatically starts another
Gaurav k sardhara Page 11
Oracle-9

ARCn process up to the maximum of 10 processes. ARCn is active only when a


database is in ARCHIVELOG mode and automatic archiving is enabled.

Recoverer (RECO)

The recoverer is used to resolve distributed transactions that are pending due to a


network or system failure in a distributed database. At timed intervals, the local
RECO attempts to connect to remote databases and automatically complete the
commit or rollback of the local portion of any pending distributed transactions.

Job Queue Processes (Jnnn)

Job queue processes are used for batch processing. Job queue processes are
managed dynamically. This enables job queue clients to use more job queue
processes when required. The resources used by the new processes are released
when they are idle.

Dispatcher (Dnnn)

Dispatchers are optional background processes, present only when a shared server


configuration is used. At least one dispatcher process is created for every
communication protocol in use (D000, . . ., Dnnn). Each dispatcher process is
responsible for routing requests from connected user processes to available shared
server processes and returning the responses back to the appropriate user
processes.

Lock Manager Server (LMS)

The Lock Manager Server process (LMS) is used for inter-instance locking in Real
Application Clusters.

Queue Monitor (QMNn)

Queue monitors are optional background processes that monitor the message


queues for Oracle Advanced Queuing. You can configure up to 10 queue monitor
processes.

Gaurav k sardhara Page 12

You might also like