Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Drishti Gupta(9991148264)
8716113
CSE(5th Sem)
Nilokheri,Karnal
Session:2016-2020
ACKNOWLEDGEMENT
First of all I would like to thanks to SLR Infotech Private
Limited - Chandigarh, itself for providing this remarkable
opportunity to be a part of the slr family which is leading
organization in the world.
I would like to thank Mr. Hitender Rana (Oracle DBA
consultant) for considering me capable of doing the tasks that I
have been performing and providing a congenial, friendly,
informal but at the same time a very professional environment to
work in, and for making me a part of his ingenious team.
In fact learning at SLR has been a continuous process
and the process is still in ‘running’ state. Also all my trainee
friends without whom, my first encountering of the corporate
life would not have been full of so much fun. They were simply
wonderful.
Last but not the least, I am grateful to my project guide
Mr. Hitender Rana for imparting their insight in my spectrum
of knowledge and for their inspiration and continual support.
SLR Infotech Pvt. Ltd. Having development office in India and Office in California USA is
one of the leading software development company with extensive experience in designing and
development cutting edge software solutions. We are a group of highly motivated it
professionals with an ability to innovate a strong desire to excel.
SLR Infotech is a customer focused company working to provide software solutions, which
are delivered with relability, timeliness, flexibility and low cost customer satisfaction as the
primary aim. The designing solutions are purely based on business and technical requirements
of the project in hand. Software development life cycle is strictly followed to ensure the timely
delivery of the project without compromising on Quality.
SLR Infotech provides a broad range of Offshore Outsourcing Services including application
and systems level programming on leading technologies. It also provides wide range of
networking solutions for Corporates, Industries and Software development Firms.
SLR Infotech has a niche in providing training to Engineering & MCA students. Thousands of
engineering students from Chandigarh, Punjab, Haryana, Rajasthan& Himachal have
successfully completed their industrial and summer Training. The focus of the industrial
training is to facilitate students with live projects on latest technologies like VB.net, ASP.net,
Oracle DBA/developer, J2EE, JDO, Struts, Linux, Networking under the strict guidance of
industry experts.
Our philosophy:-
Consistently Deliverling Ingenious, Comprehensive, Efficient and Cost-effective quality
training solutions.
Our mission:-
To Impart internationally Certified and advanced high-end it training to Engineers,
Professionals, College students in the field of Software, Hardware, Networking &Database
Administration.
Our Core Values:-
We "listen" to our students. Our relationships are based on understanding and mutual respect.
We respect, encourage and promote mutually supportive relationships in achieving common
goals. We believe in open communication, transparency & honesty in all our relationships.we
have, therefore, created a climate which is distinctive in industry. We strive to provide a
thrilling training environment that will bring innovation at work.
Upgradation Summary
\\Password=redhat\\
Password:
\\To go to terminal\\
[root@localhost ~]# su - oracle
\\To up any particular database if we have multiple database\\
[oracle@localhost ~]$ export ORACLE_SID=orcl
Oracle XDK
VALID 10.2.0.3.0
Oracle Text
VALID 10.2.0.3.0
Oracle interMedia
VALID 10.2.0.3.0
OLAP Catalog
VALID 10.2.0.3.0
Spatial
VALID 10.2.0.3.0
define
DEFINE _DATE = "30-APR-13" (CHAR)
DEFINE _CONNECT_IDENTIFIER = "orcl" (CHAR)
DEFINE _USER = "SYS" (CHAR)
DEFINE _PRIVILEGE = "AS SYSDBA" (CHAR)
DEFINE _SQLPLUS_RELEASE = "1002000300" (CHAR)
DEFINE _EDITOR = "ed" (CHAR)
DEFINE _O_VERSION = "Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 -
Production
With the Partitioning, OLAP and Data Mining options" (CHAR)
DEFINE _O_RELEASE = "1002000300" (CHAR)
DEFINE UTLIP_FILE = "nothing.sql" (CHAR)
DEFINE UPGRADE_FILE = "1002000" (CHAR)
DEFINE WPI_FILE_VAR = "owadummy.sql" (CHAR)
DEFINE OWA_FILE_VAR = "owacomm.sql" (CHAR)
DEFINE PATCH_FILE = "@nothing.sql" (CHAR)
DEFINE COMP_FILE = "@imxreg.sql" (CHAR)
DEFINE INIT_FILE = "@initxqry.sql" (CHAR)
DEFINE XDB_FILE = "@dbmsxdbt.sql" (CHAR)
DEFINE EOSCR_FILE = "@nothing.sql" (CHAR)
DEFINE 1 = "0" (CHAR)
DEFINE 2 = "synonym" (CHAR)
DEFINE 3 = "script" (CHAR)
DEFINE 4 = "for" (CHAR)
DEFINE 5 = "aw" (CHAR)
DEFINE 6 = "create" (CHAR)
DEFINE 7 = "and" (CHAR)
DEFINE 8 = "enable" (CHAR)
DEFINE 9 = "packages" (CHAR)
DEFINE EMDW_HOME = "?" (CHAR)
DEFINE EM_REPOS_USER = "SYSMAN" (CHAR)
DEFINE EM_SQL_ROOT = "?/sysman/admin/emdrep/sql" (CHAR)
DEFINE EM_REPOS_MODE = "SYSAUX" (CHAR)
DEFINE SCHEMA_UPGRADE_FILE =
"?/sysman/admin/emdrep/sql/db/v102010/db_schema_upgrade.sql" (CHAR)
DEFINE IAS_FILE =
"?/sysman/admin/emdrep/sql/core/latest/admin/admin_do_nothing.sql" (CHAR)
DEFINE OCS_FILE =
"?/sysman/admin/emdrep/sql/core/latest/admin/admin_do_nothing.sql" (CHAR)
DEFINE PKGDEF_FILE =
"?/sysman/admin/emdrep/sql/core/latest/core_sysaux_pkgdefs.sql" (CHAR)
DEFINE FUNCS_FILE = "?/sysman/admin/emdrep/sql/core/latest/core_funcs_10g.sql"
(CHAR)
DEFINE VIEWS_FILE =
"?/sysman/admin/emdrep/sql/core/latest/core_sysaux_views.sql" (CHAR)
DEFINE PKGBDYS_FILE =
"?/sysman/admin/emdrep/sql/core/latest/core_sysaux_pkgbodys.sql" (CHAR)
DEFINE TRIGGERS_FILE =
"?/sysman/admin/emdrep/sql/core/latest/core_sysaux_triggers.sql" (CHAR)
DEFINE GUID_RAW_LENGTH = "16" (CHAR)
DEFINE MAX_VARCHAR2_LENGTH = "4000" (CHAR)
DEFINE TARGET_NAME_LENGTH = "256" (CHAR)
DEFINE TARGET_TYPE_LENGTH = "64" (CHAR)
DEFINE DISPLAY_TARGET_NAME_LENGTH = "256" (CHAR)
DEFINE DISPLAY_TARGET_TYPE_LENGTH = "128" (CHAR)
DEFINE SNAPSHOT_TYPE_LENGTH = "64" (CHAR)
DEFINE USER_NAME_LENGTH = "256" (CHAR)
DEFINE NAME_LENGTH = "128" (CHAR)
DEFINE DESCRIPTION_LENGTH = "2000" (CHAR)
DEFINE SHORT_DESCRIPTION_LENGTH = "500" (CHAR)
DEFINE VERSION_LENGTH = "100" (CHAR)
DEFINE TYPE_LENGTH = "100" (CHAR)
DEFINE LOCATION_LENGTH = "1024" (CHAR)
DEFINE INET_ADDRESS_LENGTH = "20" (CHAR)
DEFINE DOMAIN_NAME_LENGTH = "500" (CHAR)
DEFINE IP_LENGTH = "20" (CHAR)
DEFINE P_NAME_LENGTH = "128" (CHAR)
DEFINE P_DESCRIPTION_LENGTH = "2000" (CHAR)
DEFINE P_SHORT_DESCRIPTION_LENGTH = "500" (CHAR)
DEFINE P_CAPTION_LENGTH = "100" (CHAR)
DEFINE P_VERSION_LENGTH = "50" (CHAR)
DEFINE P_TARGET_TYPE_LENGTH = "100" (CHAR)
DEFINE P_RULE_TYPE_LENGTH = "100" (CHAR)
DEFINE P_CATEGORY_LENGTH = "100" (CHAR)
DEFINE P_LARGE_VARCHAR_LENGTH = "4000" (CHAR)
DEFINE P_REASONABLE_NUMBER_LENGTH = "10" (CHAR)
DEFINE P_SQL_NAME_LENGTH = "31" (CHAR)
DEFINE P_VALUE_LENGTH = "1024" (CHAR)
DEFINE P_FILTER_OP_LENGTH = "10" (CHAR)
DEFINE P_SEVERITY_LENGTH = "10" (CHAR)
DEFINE P_RULE_NAME_LENGTH = "128" (CHAR)
DEFINE P_PARAM_NAME_LENGTH = "128" (CHAR)
DEFINE P_ATTRIBUTE_NAME_LENGTH = "31" (CHAR)
DEFINE P_TARGET_NAME_LENGTH = "100" (CHAR)
DEFINE P_PARAM_VALUE_LENGTH = "1024" (CHAR)
DEFINE P_ATTRIBUTE_VALUE_LENGTH = "1024" (CHAR)
DEFINE P_COLUMN_NAME_LENGTH = "31" (CHAR)
DEFINE P_Y_N_LENGTH = "1" (CHAR)
DEFINE P_SNAPSHOT_TYPE_LENGTH = "64" (CHAR)
DEFINE P_AUTHOR_LENGTH = "128" (CHAR)
DEFINE P_URL_LENGTH = "2000" (CHAR)
DEFINE P_DISPLAY_ID_LENGTH = "128" (CHAR)
DEFINE P_CLEAR = "0" (CHAR)
DEFINE ABSTRACT_LENGTH = "1024" (CHAR)
DEFINE DISPLAY_NAME_LENGTH = "128" (CHAR)
DEFINE DATA_UPGRADE_FILE =
"?/sysman/admin/emdrep/sql/db/v102010/db_data_upgrade.sql" (CHAR)
DEFINE UPDATE_TZRGN_SCRIPT =
"?/sysman/admin/emdrep/sql/core/v101050/basic/basic_update_agent_tzrgn.sql" (CHAR)
DEFINE EM_AGENT_TZRGN = "Asia/Calcutta" (CHAR)
SQL>
\\Connect to admin\\
Enter user-name: / as sysdba
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
Database altered.
\\To check the status and name of the database\\
SQL> select open_mode,name from v$database;
OPEN_MODE NAME
---------- ---------
READ ONLY PROD
\***Make the Directory named bkpp in which we will store the information
of control files,data files and pfile***\
[oracle@localhost ~]$ mkdir /u01/bkpp
[oracle@localhost ~]$ exit
exit
\\It will display the operating sysytem where we want to migrate the databse\\
SQL> select * from v$transportable_platform;
PLATFORM_ID PLATFORM_NAME
ENDIAN_FORMAT
----------- ----------------------------------------------------------------------------------------------------- --------------
1 Solaris[tm] OE (32-bit) Big
2 Solaris[tm] OE (64-bit) Big
7 Microsoft Windows IA (32-bit) Little
10 Linux IA (32-bit) Little
6 AIX-Based Systems (64-bit) Big
3 HP-UX (64-bit) Big
5 HP Tru64 UNIX Little
4 HP-UX IA (64-bit) Big
11 Linux IA (64-bit) Little
15 HP Open VMS Little
8 Microsoft Windows IA (64-bit) Little
9 IBM zSeries Based Linux Big
13 Linux 64-bit for AMD Little
16 Apple Mac OS Big
12 Microsoft Windows 64-bit for AMD Little
17 Solaris Operating System (x86) Little
18 IBM Power Based Linux Big
17 rows selected.
SQL> ho
\\Go to rman\\
[oracle@localhost ~]$ rman target/
User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
inputdatafilefno=00001 name=/u01/app/oracle/oradata/prod/system01.dbf
converteddatafile=/u01/bkpp/system01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:02:38
channel ORA_DISK_1: starting datafile conversion
inputdatafilefno=00003 name=/u01/app/oracle/oradata/prod/sysaux01.dbf
converteddatafile=/u01/bkpp/sysaux01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:01:23
channel ORA_DISK_1: starting datafile conversion
inputdatafilefno=00005 name=/u01/app/oracle/oradata/prod/example01.dbf
converteddatafile=/u01/bkpp/example01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:38
channel ORA_DISK_1: starting datafile conversion
inputdatafilefno=00002 name=/u01/app/oracle/oradata/prod/undotbs01.dbf
converteddatafile=/u01/bkpp/undotbs01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:11
channel ORA_DISK_1: starting datafile conversion
inputdatafilefno=00004 name=/u01/app/oracle/oradata/prod/users01.dbf
converteddatafile=/u01/bkpp/users01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Run SQL script /u01/bkpp/crdb.sql on the target platform to create database
Edit init.ora file /u01/app/oracle/product/10.2.0/db_1/dbs/init_00o8bhe5_1_0.ora. This
PFILE will be used to create the database on the target platform
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
To change the internal database identifier, use DBNEWID Utility
Finished backup at 30-APR-13
RMAN>
• TRUNCATE deletes all data from a table in a very fast way, deleting the data
inside the table and not the table itself. It usually implies a subsequent COMMIT
operation, i.e., it cannot be rolled back.TRUNCATE TABLE My_table;
Example:
GRANT SELECT, UPDATE
ON My_table
TO some_user, another_user;
• SAVE TRANSACTION (or SAVEPOINT ) save the state of the database at the
current point in transaction
• ROLLBACK causes all data changes since the last COMMIT or ROLLBACK to
be discarded, leaving the state of the data as it was prior to those changes
SQL FUNCTIONS
Single row function:-
Single row or Scalar functions return a value for every row that is processed in a query. Here are
four types of single row functions. They are:
Numeric Functions: These are functions that accept numeric input and return
numeric values. Numeric functions are used to perform operations on numbers. They
accept numeric values as input and return numeric values as output.
Character Functions
Date Functions: These are functions that take values that are of datatype
DATE as input and return values of datatype DATE, except for the
MONTHS_BETWEEN function, which return a number.
The below table provides the examples for the above functions:-
Return
Function Name Examples
Value
ADD_MONTHS ( ) ADD_MONTHS ('16-Sep-81', 3) 16-Dec-81
MONTHS_BETWEEN( MONTHS_BETWEEN ('16-Sep-81',
3
) '16-Dec-81')
NEXT_DAY( ) NEXT_DAY ('01-Jun-08', 'Wednesday') 04-JUN-08
LAST_DAY( ) LAST_DAY ('01-Jun-08') 30-Jun-08
NEW_TIME( ) NEW_TIME ('01-Jun-08', 'IST', 'EST') 31-May-08
DATE Functions
The below table provides the examples for the above functions.
Function
Examples Return Value
Name
TO_CHAR (3000, '$9999') $3000
TO_CHAR
TO_CHAR (SYSDATE, 'Day, Month Monday, June
()
YYYY') 2008
TO_DATE
TO_DATE ('01-Jun-08') 01-Jun-08
()
SQL COUNT (): This function returns the number of rows in the table that
satisfies the condition specified in the WHERE condition. If the WHERE condition is not
specified, then the query returns the total number of rows in the table.
For Example: If you want the number of employees in a particular
department, the query would be:
SELECT COUNT (*) FROM employee.
WHERE dept = 'Electronics';
SQL DISTINCT (): This function is used to select the distinct rows.
For Example: If you want to select all distinct department names from
employee table, the query would be:
SELECT DISTINCT dept FROM employee;
SQL MAX (): This function is used to get the maximum value from a column.
To get the maximum salary drawn by an employee, the query would be:
SELECT MAX (salary) FROM employee;
SQL MIN (): This function is used to get the minimum value from a column.
To get the minimum salary drawn by an employee, he query would be:
SELECT MIN (salary) FROM employee;
SQL AVG (): This function is used to get the average value of a numeric column.
To get the average salary, the query would be:
SELECT AVG (salary) FROM employee;
SQL SUM(): This function is used to get the sum of a numeric column
To get the total salary given out to the employees,
SELECT SUM (salary) FROM employee;
SQL Joins:
SQL Joins are used to relate information in different tables. A Join condition is a part of the SQL
query that retrieves rows from two or more tables. A SQL Join condition is used in the SQL
WHERE Clause of select, update, delete statements.
The Syntax for joining two tables is:
SELECT col1, col2, col3
FROM table_name1, table_name2
WHERE table_name1.col2 = table_name2.col1;
If a SQL join condition is omitted or if it is Invalid the join operation will result in a Cartesian
product. The Cartesian product returns a number of rows equal to the product of all rows in all
the tables being joined. For example, if the first table has 20 rows and the second table has 10
rows, the result will be 20 * 10 or 200 rows. This query takes a long time to execute.
1.Unique Key:- This constraint ensures that a column or a group of columns in each row
have a distinct value. A column(s) can have a null value but the values cannot be duplicated.
Syntax to define a Unique key at column level:
[CONSTRAINT constraint_name] UNIQUE
Syntax to define a Unique key at table level:
[CONSTRAINT constraint_name] UNIQUE(column_name)
2.Check Constraint: -This constraint defines a business rule on a column. All the
rows must satisfy this rule. The constraint can be applied for a single column or a group of
columns.
Syntax to define a Check constraint:
[CONSTRAINT constraint_name] CHECK (condition)
SQL VIEW
SQL VIEW is a virtual table, through which a selective portion of the data from one or more
tables can be seen. Views do not contain data of their own. They are used to restrict access to the
database or to hide data complexity. A view is stored as a SELECT statement in the database.
DML operations on a view like INSERT, UPDATE, DELETE affects the data in the original
table upon which the view is based.
The Syntax to create a SQL view is:-
CREATE VIEW view_name
AS
SELECT column_list
FROM table_name [WHERE condition];
Creating a view:-
CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view name [alias[, alias]…)]
AS subquery
[WITH CHECK OPTION [CONSTRAINT constraint] ]
[WITH READ ONLY]
Modifying views:-
You cannot modify a view using the ALTER .. MODIFY clause. To modify the view you have
to drop it and create another one, or you can simply use the [OR REPLACE] clause and replace
the existing view.
SQL> CREATE OR REPLACE VIEW myview
AS SELECT empno EMPLOYEE_NO, ename NAME, sal SALARY
FROM emp
WHERE deptno=10;
Rules for performing DML Operations on a view:-
• You can perform DML operations on Simple views.
• You cannot remove a row if the view contains the following:
• Group functions such as SUM, MIN, MAX, AVG, …
• A GROUP BY clause.
• The DISTINCT keyword.
• You cannot modify data in a view if it contains:
• Group functions such as SUM, MIN, MAX, AVG, …
• A GROUP BY clause.
• The DISTINCT keyword.
• Columns defined by expressions (i.e, SAL * 12).
• The ROWNUM pseudo column.
• You cannot add data if:
• The view contains any of the conditions mentioned above.
• There are NOT NULL columns in the base tables that are not selected by the view.
Any attempt to change the department number for any row in the view fails because it violates
the WITH CHECK OPTION constraint.
Any attempt to perform DML on any row in the view results in an Oracle server error: ORA-
01725
Removing a view:-
Remove the view without losing data because a view is based on underlying tables in the
database:
DROP VIEW view;
SQL Index
When there are thousands of records in a table, retrieving information will take a long time.
Therefore indexes are created on columns which are accessed frequently, so that the information
can be retrieved quickly. Indexes can be created on a single column or a group of columns.
When a index is created, it first sorts the data and then it assigns a ROWID for each row.
Syntax to create Index:
CREATE INDEX index_name
ON table_name (column_name1,column_name2...);
Syntax to create SQL unique Index:
CREATE UNIQUE INDEX index_name
ON table_name (column_name1,column_name2...);
In Oracle there are two types of SQL index namely, implicit and explicit.
Implicit Indexes:
They are created when a column is explicity defined with PRIMARY KEY, UNIQUE KEY
Constraint.
Explicit Indexes:
They are created using the "create index.. " syntax.
.
Privileges and Roles
Privileges: Privileges defines the access rights provided to a user on a database object.
There are two types of privileges.
1) System privileges - This allows the user to CREATE, ALTER, or DROP database objects.
2) Object privileges - This allows the user to EXECUTE, SELECT, INSERT, UPDATE, or
DELETE data from database objects to which the privileges apply.
System Privileges
Object
Description
Privileges
INSERT Allows users to insert rows into a table.
SELECT Allows users to select data from a database object.
UPDATE Allows user to update data in a table.
EXECUTE Allows user to execute a stored procedure or a function.
Object Privileges
Roles: Roles are a collection of privileges or access rights. When there are many users in a
database it becomes difficult to grant or revoke privileges to users. Therefore, if you define roles,
you can grant or revoke privileges to users, thereby automatically granting or revoking
privileges. You can either create Roles or use the system roles pre-defined by oracle.
Some of the privileges granted to the system roles are as given below:
System Role Privileges Granted to the Role
CREATE TABLE, CREATE VIEW, CREATE SYNONYM, CREATE
CONNECT
SEQUENCE, CREATE SESSION etc.
CREATE PROCEDURE, CREATE SEQUENCE, CREATE TABLE,
RESOURCE CREATE TRIGGER etc. The primary usage of the RESOURCE role is to
restrict access to database objects.
To revoke a CREATE TABLE privilege from testing ROLE, you can write:
REVOKE CREATE TABLE FROM testing;
The Syntax to drop a role from the database is as below:
DROP ROLE role_name;
Database Structures
Each running Oracle database is associated with an Oracle instance. When a database is started
on a database server, the Oracle software allocates a shared memory area called the System
Global Area (SGA) and starts several Oracle background processes. This combination of the
SGA and the Oracle processes is called an Oracle instance.
After starting an instance, the Oracle software associates the instance with a specific database.
This is called mounting the database. The database is then ready to be opened, which makes it
accessible to authorized users. Multiple instances can execute concurrently on the same
computer, each accessing its own physical database.
Automatic Storage Management spreads database data across all disks, creates and maintains a
storage grid, and provides the highest input/output (I/O) throughput with minimal management
costs. As disks are added or dropped, ASM redistributes the data automatically. (There is no
need for a logical volume manager to manage the file system.) Data availability increases with
optional mirroring, and you can add or drop disks online. For more information, see the lesson
titled “Managing Database Storage Structures.”
With the advent of so many big enterprises, the need to create a more sophisticated DBMS has
also increased. For appointment as a DBA, a high level of skill and expertise is required. The
major tasks that should be performed by a DBA are as follows:
• Judging what server hardware will be required to run the Oracle 10g database software
• Installing and configuring the Oracle 10g database software on the server hardware
• Creating a database and managing tables and other database objects
• Creating and managing database users
• Configuring backup and recovery processes for the database
• Monitoring and tuning the database performance
Now, the point is how a DBA can perform the above-mentioned tasks. To perform all these tasks
in an efficient manner, a DBA must be very well versed with the underlying Oracle architecture.
The Control File: Though it is the smallest file (1MB-5MB) of the database, it is the
most crucial and critical file. The criticality of this file is ascribed to the fact that if it is damaged
then the database recovery operation becomes tedious. It contains the requisite information to
start the database. The names and locations of all the control files of the database can be obtained
from the V$CONTROLFILE dynamic performance view.
Data files: These hold data that is stored in tables of a database. They are usually the
largest files in the database, ranging in size from MB, GB, to TB.
Redo Log files: These files contain information that helps in recovery in the event of
system failure. It contains information stored in the Redo Log Buffer. The information in the
Redo Log Buffer is written into Redo Log files by the LGWR background process. The Redo
Log files are generally multiplexed and copied for recovery purposes. Sets of redo Log files are
known as Redo Log groups. Each database has minimum of two Redo Log groups. Redo Log
groups are used in a circular fashion.
The figure below depicts the use of Redo Log files in circular fashion:
Fig.
3.3 Redo Log Buffer
The figure above shows three Redo Log groups. Each group consists of two members. The first
member of each Redo Log group is stored in directory D1 and the second member is stored in
directory D2.
Note:
• The V$LOGFILE dynamic performance view is used to obtain information about the
names and locations of the Redo Log groups and their members.
• LGWR writes every three seconds to a Redo Log group in the case of the following
events:
• Whenever a user commits a transaction
• Whenever the Redo Log Buffer is one-third (1/3) full
The Oracle memory structure
The most basic components of Oracle memory are:
• SGA- It stands for System Global Area. SGA is allocated whenever an Oracle instance
starts and gets de-allocated when the Oracle instance is shutdown.
• Components of SGA:
• The Database Buffer Cache
• The Redo Log Buffer
• The Shared Pool
• PGA- It stands for Program Global Area. It is a region in memory that contains data
and control information for a single process. This can be either a server or a background process.
A PGA is allocated whenever an Oracle database user connects to a database and a session is
created for him/her.
Oracle processes
There are two categories of processes that run with an Oracle database. They are mentioned
below:
• User processes
• Server processes
Fig. 3.4 The relationship between user processes, server processes, PGA, and session.
The first interaction with the Oracle-based application comes from the user computer that creates
a user process. The user process then communicates with the server process on the host
computer. Here, PGA is used to store session specific information.
Archive Mode
When you run a database in ARCHIVELOG mode, you enable the archiving of the online redo
log. The database control file indicates that a group of filled online redo log files cannot be used
by LGWR until the group is archived. A filled group is immediately available for archiving after
a redo log switch occurs.
The archiving of filled groups has these advantages:
• A database backup, together with online and archived redo log files, guarantees that you
can recover all committed transactions in the event of an operating system or disk failure.
• You can use a backup taken while the database is open and in normal system use if you
keep an archived log.
• You can keep a standby database current with its original database by continually
applying the original's archived redo logs to the standby.
Decide how you plan to archive filled groups of the online redo log. You can configure an
instance to archive filled online redo log files automatically, or you can archive manually. For
convenience and efficiency, automatic archiving is usually best. Figure 5 illustrate how the
process archiving the filled groups (ARC0 in this illustration) generates the database's online
redo log.
• A tablespaceis made up of one or more data files. These files might be cooked files in a
file system, raw partitions, ASM managed database files, or a file on a clustered file system. A
tablespace contains segments.
• A segment (TABLE, INDEX, and so on) is made up of one or more extents. A segment
exists in a tablespace, but may have data in many data files within that tablespace.
• An extent is a logically contiguous set of blocks on disk. An extent is in a single
tablespace and, furthermore, is always in a single file within that tablespace.
• A block is the smallest unit of allocation in the database. A block is the smallest unit of
I/O used by a database.
Tablespace
A tablespace is a logical storage unit within an Oracle database. It is logical because a tablespace
is not visible in the file system of the machine on which the database resides. A tablespace, in
turn, consists of at least one datafile which, in turn, are physically located in the file system of
the server. Btw, a datafile belongs to exactly one tablespace.
Each table, index and so on that is stored in an Oracle database belongs to a tablespace. The
tablespace builds the bridge between the Oracle database and the filesystem in which the table's
or index' data is stored.
There are three types of tablespaces in Oracle:
• Permanent Tablespaces
• Undo Tablespaces
• Temporary Tablespaces
A tablespace is created with the Create Tablespace SQL command.
A database running in automatic Undo Management mode transparently creates and manages
undo segments. Oracle DBA can create an Undo tablespace and determine the maximum
retention time for undo data kept in that tablespace.
Temporary Tablespaces improve the concurrence of multiple sort operations, reduce their
overhead, or avoid Oracle space management operations altogether. Temporary tablespaces are
the most efficient tablespaces for disk sorts. Space management (extent allocation and de-
allocation) is locally managed. After temporary tablespaces, tablespaces of type TEMPORARY
are the next best tablespaces to use for sort operations. Space management is dictionary
managed.
Permanent Tablespaces (which are not of type TEMPORARY) are least efficient for
performance of disk sorts.
Temporary and Permanent Tablespaces can be assigned at the user level. Oracle DBA can create
a default temporary tablespace at database creation time. This tablespace is used as the default
temporary tablespace for users who are not otherwise assigned a temporary tablespace.
The Results page shows all tablespaces, including the following information about each: type of
tablespace, type of extent management, type of segment management, status, size, and percent
used. Click the tablespace name for more information
Mount:
Mounting a database includes the following tasks:
• Associating a database with a previously started instance
• Locating and opening the control files specified in the parameter file
• Reading the control files to obtain the names and statuses of the data files and online redo
log files. However, no checks are performed to verify the existence of the data files and online
redo log files at this time.
• To perform specific maintenance operations, start an instance and mount a database, but
do not open the database.
• For example, the database must be mounted but must not be opened during the following
tasks:
• Renaming data files (Data files for an offline tablespace can be renamed when the
database is open.)
• Enabling and disabling online redo log file archiving options
• Performing full database recovery
Open:
A normal database operation means that an instance is started and the database is mounted and
opened. With a normal database operation, any valid user can connect to the database and
perform typical data access operations.
Opening the database includes the following tasks:
• Opening the online data files
• Opening the online redo log files
If any of the data files or online redo log files are not present when you attempt to open the
database, then the Oracle server returns an error. During this final stage, the Oracle server
verifies that all the data files and online redo log files can be opened and checks the consistency
of the database. If necessary, the System Monitor (SMON) background process initiates instance
recovery.
You can start up a database instance in restricted mode so that it is available to users with
administrative privileges only. To start an instance in restricted mode, select the "Restrict access
to database" option on the Advanced Startup Options page.
• SHUTDOWN ABORT
• 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.
• Uncommitted transactions are not rolled back.
• Oracle Database does not wait for users currently connected to the database to
disconnect. The database implicitly disconnects all connected users.
-The next startup of the database will require instance recovery procedures.
Websites
• www.oracle.com/pls/db102/homepage
• www.sqlasia.com
• http://faq.programmerworld.net/database/installing-oracle-10g.html
• http://www.oracle.com/technetwork/database/database10g/documentation/database10gr2-
087366.html
• http://www.oracle.com/technetwork/database/database10g/documentation/index.html