SlideShare a Scribd company logo
Database structure and space
Management
Database Structure
• An ORACLE database has both a physical
and logical structure. By separating
physical and logical database structure,
the physical storage of data can be
managed without affecting the access to
logical storage structures.
Database
structures
Logical Physical
Logical Database Structure
1. Tablespace - stores related database objects
2. Segments - stores an individual database object, such
as a table or an index
3. Extent - a contiguous unit of storage space within a
segment
4. Data Block - smallest storage unit that the database
can address. Extents consist of data blocks
Logical Database Structure
Segments
Data blocks
Extents Extents
Tablespace
Tablespace
• Each Database is logically divided into one or more table
spaces
• Table space can be online (accessible) {default} or offline
(Not accessible(
• You can create a new tablespace to increase the size of a
database
• The database Administrator can bring any tablespace in an
oracle online or offline
• Oracle Database automatically switches a tablespace from
online to offline when certain errors are encountered. For
example, Oracle Database switches a tablespace from
online to offline when the database writer process, DBWn,
fails in several attempts to write to a datafile of the
tablespace
Tablespace
• Every Oracle database contains at least two tablespaces
named SYSTEM and SYSUAX which Oracle Database
creates automatically when the database is created.
• The SYSTEM tablespace contains Data Dictionary and
it’s always online when the database is open.
• Data Dictionary contain Metadata which is data about
data
– Who created the table?
– What columns are there in the table?
– When the table is created?
• The SYSAUX tablespace is an auxiliary tablespace to
the SYSTEM tablespace. The SYSAUX tablespace
provides a centralized location for database metadata
that does not reside in the SYSTEM tablespace
Temporary tablespace
• Temporary tablespaces provide performance
improvements when you have multiple sorts that
are too large to fit into memory
• All operations that use sorts, including joins,
union, index builds, ordering (ORDER BY) and
computing aggregates (GROUP BY), benefit
from temporary tablespaces.
• Temporary tablespace is named TEMP. It is
optional and permanent in nature but their
segment are temporary in nature.
Read-only tablespace
• The primary purpose of read-only tablespaces is to
eliminate the need to perform backup and recovery of
large, static portions of a database.
• Oracle Database never updates the files of a read-only
tablespace
• Because read-only tablespaces cannot be modified, and
as long as they have not been made read/write at any
point, they do not need repeated backup.
Database, Tablespaces, and data
files
• Oracle stores data logically in
tablespaces and physically in
datafiles associated with the
corresponding tablespace.
database-stucture-and-space-managment.ppt
Database, Tablespaces, and data
files
• The relationship among databases,
tablespaces, and data files :
1. Each database is logically divided into one or
more tablespaces.
2. One or more data files are explicitly created for
each tablespace to physically store the data of all
logical structures in a tablespace.
3. The combined size of a tablespace's data files in
the total storage capacity of the tablespace.
4. The combined storage capacity of a database's
tablespaces is the total storage capacity of the
database
Allocate More Space for a
Database
• The size of a tablespace is the size of the
datafiles that constitute the tablespace. The size
of a database is the collective size of the
tablespaces that constitute the database.
• You can enlarge a database in three ways:
– Add a datafile to a tablespace
– Add a new tablespace
– Increase the size of a datafile
• When you add another datafile to an existing
tablespace, you increase the amount of disk
space allocated for the corresponding
tablespace
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
Create table space
• CREATE TABLESPACE tablespace_name
DATAFILE file_name [SIZE integer M] [REUSE]
DEFAULT STORAGE (
INITIAL integer M
NEXT integer M
MINEXTENTS integer
MAXEXTENTS integer
PCTINCREASE integer)
ONLINE or OFFLINE
PERMANENT or TEMPORARY;
Create table space
• TABLESPACE : Tablespace in which you want the
table to reside.
• INITIAL SIZE: The size for the initial extent of the
table.
• NEXT SIZE: The value for any additional extents the
table may take through growth.
• MINEXTENTS and MAXEXTENTS: Identify the
minimum and maximum extents allowed for the table.
• PCTINCREASE: Identifies the percentage the next
extent will be increased each time the table grows, or
takes another extent.
Example
• CREATE TABLESPACE tp
DATAFILE 'df.ora' SIZE 10M
DEFAULT STORAGE(
INITIAL 10K
NEXT 50K
MINEXTENTS 1
MAXEXTENTS 999
PCTINCREASE 10)
ONLINE
permanent;
Create Table
• SQL Statement:CREATE TABLE table_name
(column_name data_type [DEFAULT exp]
[CONSTRAINT])
TABLESPACE tablespace_name
STORAGE (INITIAL size K or M
NEXT size K or M
MINEXTENTS value
MAXEXTENTS value
PCTINCREASE value);
Example
• CREATE TABLE maha (
id NUMBER CONSTRAINT co_id PRIMARY
KEY,
name varchar(20))
TABLESPACE tp STORAGE (
INITIAL 7000
NEXT 7000
MINEXTENTS 1
MAXEXTENTS 5
PCTINCREASE 5);
Table space
• Most major RDBMSs have default
settings for table sizes and table
locations.
• If you do not specify table size and
location, then the table will take the
defaults.
• The defaults may be very undesirable,
especially for large tables.
Segments
• The level of logical database storage above an
extent is called a segment. A segment is a set
of extents allocated for a certain logical
structure.
• the different types of segments include:
1. Data segments
• Every table in an Oracle database has a single data
segment
2. Index segments
• Every index in an Oracle database has a single index
segment holds all of its data
3. Temporary segments
– Temporary segments are created by
ORACLE. When a SQL statement needs a
temporary work area to complete execution.
When the statement finishes execution, the
temporary segments extents are returned to
the system for future use.
4. Rollback segments
It records old values of data that was changed
by each transaction.. “Undo Information”
Rollback segments
Rollback segments are areas in your database
which are used to temporarily save the
previous values when some updates
occurred
• have two main purposes :
1. If for one reason or another the user wants to
cancel his/her update with a ROLLBACK
statement, the former values are restored. This
is possible only during the life of the
transaction. If the user executes COMMIT
instead, the values in the rollback segment are
marked as invalidated and the change becomes
permanent .
2. This is where other, concurrent
sessions read the data when they
access the changed tables before the
transactions are committed. Note that
if a SELECT starts on a table while a
transaction is modifying the same
table, the old value of the data will be
read from a rollback segment - some
queries take a pretty long time to run
Advantages of COMMIT
and ROLLBACK Statements
• With COMMIT and ROLLBACK
statements, you can:
• Ensure data consistency
• Preview data changes before making
changes permanent
State of the Data After
ROLLBACK
• Discard all pending changes by using
the ROLLBACK
statement:
• Data changes are undone.
• Previous state of the data is restored.
• Locks on the affected rows are released.
DELETE FROM copy_emp;
22 rows deleted.
ROLLBACK;
Rollback complete
database-stucture-and-space-managment.ppt
description
statement
Ends the current transaction by making all pending
data changes
permanent
COMMIT
Marks a savepoint within the current transaction
SAVEPOINT
name
ends the current transaction by discarding all
pending
data changes
ROLLBACK
ROLLBACK TO SAVEPOINT rolls back the current
transaction to
the specified savepoint, thereby discarding any changes
created after the savepoint to which you are rolling back.
If you omit the TO SAVEPOINT clause, the ROLLBACK
statement
rolls back the entire transaction. As savepoints are logical,
there is
no way to list the savepoints you have created.
ROLLBACK TO
SAVEPOINT name
Rolling Back Changes
to a Marker
• Create a marker in a current transaction by using
the SAVEPOINT statement.
• Roll back to that marker by using the ROLLBACK
TO SAVEPOINT statement.
• Example:UPDATE...........
SAVEPOINT update_done;
Savepoint created.
INSERT...........
ROLLBACK TO update_done;
Rollback complete.
State of the Data After COMMIT
• Data changes are made permanent in the
database.
• The previous state of the data is
permanently lost.
• All users can view the results.
• All savepoints are erased.
Committing Data
• Make the changes.
DELETE FROM employees
WHERE employee_id = 99999;
1 row deleted.
INSERT INTO departments
VALUES (290, 'Corporate Tax', NULL,
1700);
1 row inserted.
• Commit the changes.
COMMIT;
Commit complete.
Data blocks
• An ORACLE database's data is stored in data
blocks.
• One data block corresponds to a specific
number of bytes of physical database space on
disk.‘
• A data block size is specified for each ORACLE
database when the database is created.
• A database uses and allocates free database
space in ORACLE data blocks
Data blocks
• Each Data Block consists of: header, free space
and row data
– Header - contains information about the data block
contents, and is made up of three separate
subsections: the block header, the table directory,
and the row directory
– Free space - is empty space that the block retains in
case users update the data within the data block, and
the updated data occupies more storage space than
the original data
– Row Data – stores actual data values
Data Block Components
Physical Database Structure
• An ORACLE database's physical structure
is determined by the operating system files
that constitute the database.
• The files of a database provide the actual
physical storage for database information
Physical Database Structure
1. Datafiles – contain the actual data values
2. Redo log files - record all changes made
to data, including both uncommitted and
committed changes.
3. Control files - contain information about
the database tablespaces, datafiles, redo
log files, and the current state of the
database Ex. Database name
Data Files
• Every ORACLE database has one or more
physical data files.
• A database's data files contain all the
database data.
• The data of the logical database structures
such as tables and indexes is physically
stored in the data files allocated for a
database.
Data files
• A Data file can be associated with only
one database
• One or more datafiles are explicitly
created for each tablespace to physically
store the data of all logical structures
Redo log files
• The primary function of the redo log is to
record all changes made to data.
• The information in a redo log file is used
only to recover the database from a
system or media failure that prevents
database from being written to database's
data files.
Control Files
• Every ORACLE database has a control file. A
control file records the physical structure of the
database. For example, it contains the
following types of information:
- database name
- names and locations of a database's data
files and redo log files
- time stamp of database creation
• You should create two or more copies of the
control file during database creation.

More Related Content

PPTX
Performance evolution of raid
PDF
Google File System
DOCX
Os solved question paper
PPT
Virtual memory
PPTX
Hadoop Distributed File System
PPTX
Administration and Management of Users in Oracle / Oracle Database Storage st...
PPT
Google file system
DOCX
Linux crontab
Performance evolution of raid
Google File System
Os solved question paper
Virtual memory
Hadoop Distributed File System
Administration and Management of Users in Oracle / Oracle Database Storage st...
Google file system
Linux crontab

What's hot (20)

PDF
Performance optimization for all flash based on aarch64 v2.0
PDF
Hadoop YARN
PDF
re:Invent 2019 BPF Performance Analysis at Netflix
PDF
SRE Conference 2022 - How to Build a Healthy On-Call Culture
PDF
Architecture for building scalable and highly available Postgres Cluster
PPTX
PDF
Comparison of-foss-distributed-storage
PPTX
The oracle database architecture
PDF
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
PDF
Database Systems - A Historical Perspective
PPT
PPT
Snooping protocols 3
PPT
Distributed & parallel system
PDF
Deep-Dive into Big Data ETL with ODI12c and Oracle Big Data Connectors
PPTX
Segmentation in operating systems
PPTX
8 drived horizontal fragmentation
PPTX
Map reduce presentation
DOCX
Test Lab Guide: Windows Server 2012 R2 Base Configuration
PPT
google file system
PDF
Relational Databases to Riak
Performance optimization for all flash based on aarch64 v2.0
Hadoop YARN
re:Invent 2019 BPF Performance Analysis at Netflix
SRE Conference 2022 - How to Build a Healthy On-Call Culture
Architecture for building scalable and highly available Postgres Cluster
Comparison of-foss-distributed-storage
The oracle database architecture
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Database Systems - A Historical Perspective
Snooping protocols 3
Distributed & parallel system
Deep-Dive into Big Data ETL with ODI12c and Oracle Big Data Connectors
Segmentation in operating systems
8 drived horizontal fragmentation
Map reduce presentation
Test Lab Guide: Windows Server 2012 R2 Base Configuration
google file system
Relational Databases to Riak
Ad

Similar to database-stucture-and-space-managment.ppt (20)

PPTX
tablespaces and datafiles in database administration
PPTX
Oracle architecture with details-yogiji creations
PPTX
12. oracle database architecture
PPT
Online Oracle Training For Beginners
PPT
1650607.ppt
PPT
Oracle training-in-hyderabad
PPT
Introduction to oracle
PPT
Introduction to oracle(2)
PPT
Introduction to oracle
PPTX
An Introduction To Oracle Database
PDF
02-Oracle 19c-Storage-Management de Base de Datos
PPTX
Oracle DBA Tutorial for Beginners -Oracle training institute in bangalore
PDF
MS-SQL SERVER ARCHITECTURE
PPTX
Relational Database Management System
PPT
Week 10-11 Managing Tablespaces and Data Files.ppt
PDF
DBA 101 : Calling all New Database Administrators (WP)
PDF
Oracle tutorial
PPS
Oracle Database Overview
tablespaces and datafiles in database administration
Oracle architecture with details-yogiji creations
12. oracle database architecture
Online Oracle Training For Beginners
1650607.ppt
Oracle training-in-hyderabad
Introduction to oracle
Introduction to oracle(2)
Introduction to oracle
An Introduction To Oracle Database
02-Oracle 19c-Storage-Management de Base de Datos
Oracle DBA Tutorial for Beginners -Oracle training institute in bangalore
MS-SQL SERVER ARCHITECTURE
Relational Database Management System
Week 10-11 Managing Tablespaces and Data Files.ppt
DBA 101 : Calling all New Database Administrators (WP)
Oracle tutorial
Oracle Database Overview
Ad

More from Iftikhar70 (20)

PPT
m1-intro artificial intelligence for .ppt
PPTX
introductioartificial intelligencen.pptx
PPT
dcscw07aetificial intelligence for 1.ppt
PPT
Ch1-2 (artificial intelligence for 3).ppt
PPTX
توظيف ادوات الذكاء الاصطناعي في البحث العلمي الاعلامي - saad kadhim.pptx
PPTX
introduction technology technology tec.pptx
PPT
cps270_game_playing technology intelligence.ppt
PPT
Chapter_9_Morphological_Image_Processing.ppt
PPTX
10_2020_12_10!09_25_23_AM technology.pptx
PPT
14580hffggcdfghcfgvcsdvbcdgbvcdgg968.ppt
PPT
1424403vfdfdfghljhhggvgfggffgddgd6trf.ppt
PPT
12_2017_09_17!02_48_41_Aengerrings M.ppt
PPTX
امن سيبر اني للحوسبة في الجزء الثاني.pptx
PPT
Alhadeff cloud computing cyber technology.ppt
PPT
Introduction to artificial intelligence.ppt
PPTX
777137036 image processing bacherde.pptx
PPT
m1-intro artificial intelligence tec.ppt
PPT
cps270_intro artificial intelligence.ppt
PPT
cps270_game_playing artificial intelligence.ppt
PPTX
في الذكاء الاصطناعي وتقنيه المعلوماتالعملي.pptx
m1-intro artificial intelligence for .ppt
introductioartificial intelligencen.pptx
dcscw07aetificial intelligence for 1.ppt
Ch1-2 (artificial intelligence for 3).ppt
توظيف ادوات الذكاء الاصطناعي في البحث العلمي الاعلامي - saad kadhim.pptx
introduction technology technology tec.pptx
cps270_game_playing technology intelligence.ppt
Chapter_9_Morphological_Image_Processing.ppt
10_2020_12_10!09_25_23_AM technology.pptx
14580hffggcdfghcfgvcsdvbcdgbvcdgg968.ppt
1424403vfdfdfghljhhggvgfggffgddgd6trf.ppt
12_2017_09_17!02_48_41_Aengerrings M.ppt
امن سيبر اني للحوسبة في الجزء الثاني.pptx
Alhadeff cloud computing cyber technology.ppt
Introduction to artificial intelligence.ppt
777137036 image processing bacherde.pptx
m1-intro artificial intelligence tec.ppt
cps270_intro artificial intelligence.ppt
cps270_game_playing artificial intelligence.ppt
في الذكاء الاصطناعي وتقنيه المعلوماتالعملي.pptx

Recently uploaded (20)

PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PDF
.pdf is not working space design for the following data for the following dat...
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
Major-Components-ofNKJNNKNKNKNKronment.pptx
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPTX
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
PPTX
1_Introduction to advance data techniques.pptx
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PPT
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Supervised vs unsupervised machine learning algorithms
STUDY DESIGN details- Lt Col Maksud (21).pptx
.pdf is not working space design for the following data for the following dat...
Introduction to Knowledge Engineering Part 1
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Business Acumen Training GuidePresentation.pptx
Major-Components-ofNKJNNKNKNKNKronment.pptx
IBA_Chapter_11_Slides_Final_Accessible.pptx
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
1_Introduction to advance data techniques.pptx
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
Galatica Smart Energy Infrastructure Startup Pitch Deck

database-stucture-and-space-managment.ppt

  • 1. Database structure and space Management
  • 2. Database Structure • An ORACLE database has both a physical and logical structure. By separating physical and logical database structure, the physical storage of data can be managed without affecting the access to logical storage structures.
  • 4. Logical Database Structure 1. Tablespace - stores related database objects 2. Segments - stores an individual database object, such as a table or an index 3. Extent - a contiguous unit of storage space within a segment 4. Data Block - smallest storage unit that the database can address. Extents consist of data blocks
  • 5. Logical Database Structure Segments Data blocks Extents Extents Tablespace
  • 6. Tablespace • Each Database is logically divided into one or more table spaces • Table space can be online (accessible) {default} or offline (Not accessible( • You can create a new tablespace to increase the size of a database • The database Administrator can bring any tablespace in an oracle online or offline • Oracle Database automatically switches a tablespace from online to offline when certain errors are encountered. For example, Oracle Database switches a tablespace from online to offline when the database writer process, DBWn, fails in several attempts to write to a datafile of the tablespace
  • 7. Tablespace • Every Oracle database contains at least two tablespaces named SYSTEM and SYSUAX which Oracle Database creates automatically when the database is created. • The SYSTEM tablespace contains Data Dictionary and it’s always online when the database is open. • Data Dictionary contain Metadata which is data about data – Who created the table? – What columns are there in the table? – When the table is created? • The SYSAUX tablespace is an auxiliary tablespace to the SYSTEM tablespace. The SYSAUX tablespace provides a centralized location for database metadata that does not reside in the SYSTEM tablespace
  • 8. Temporary tablespace • Temporary tablespaces provide performance improvements when you have multiple sorts that are too large to fit into memory • All operations that use sorts, including joins, union, index builds, ordering (ORDER BY) and computing aggregates (GROUP BY), benefit from temporary tablespaces. • Temporary tablespace is named TEMP. It is optional and permanent in nature but their segment are temporary in nature.
  • 9. Read-only tablespace • The primary purpose of read-only tablespaces is to eliminate the need to perform backup and recovery of large, static portions of a database. • Oracle Database never updates the files of a read-only tablespace • Because read-only tablespaces cannot be modified, and as long as they have not been made read/write at any point, they do not need repeated backup.
  • 10. Database, Tablespaces, and data files • Oracle stores data logically in tablespaces and physically in datafiles associated with the corresponding tablespace.
  • 12. Database, Tablespaces, and data files • The relationship among databases, tablespaces, and data files : 1. Each database is logically divided into one or more tablespaces. 2. One or more data files are explicitly created for each tablespace to physically store the data of all logical structures in a tablespace. 3. The combined size of a tablespace's data files in the total storage capacity of the tablespace. 4. The combined storage capacity of a database's tablespaces is the total storage capacity of the database
  • 13. Allocate More Space for a Database • The size of a tablespace is the size of the datafiles that constitute the tablespace. The size of a database is the collective size of the tablespaces that constitute the database. • You can enlarge a database in three ways: – Add a datafile to a tablespace – Add a new tablespace – Increase the size of a datafile • When you add another datafile to an existing tablespace, you increase the amount of disk space allocated for the corresponding tablespace
  • 17. Create table space • CREATE TABLESPACE tablespace_name DATAFILE file_name [SIZE integer M] [REUSE] DEFAULT STORAGE ( INITIAL integer M NEXT integer M MINEXTENTS integer MAXEXTENTS integer PCTINCREASE integer) ONLINE or OFFLINE PERMANENT or TEMPORARY;
  • 18. Create table space • TABLESPACE : Tablespace in which you want the table to reside. • INITIAL SIZE: The size for the initial extent of the table. • NEXT SIZE: The value for any additional extents the table may take through growth. • MINEXTENTS and MAXEXTENTS: Identify the minimum and maximum extents allowed for the table. • PCTINCREASE: Identifies the percentage the next extent will be increased each time the table grows, or takes another extent.
  • 19. Example • CREATE TABLESPACE tp DATAFILE 'df.ora' SIZE 10M DEFAULT STORAGE( INITIAL 10K NEXT 50K MINEXTENTS 1 MAXEXTENTS 999 PCTINCREASE 10) ONLINE permanent;
  • 20. Create Table • SQL Statement:CREATE TABLE table_name (column_name data_type [DEFAULT exp] [CONSTRAINT]) TABLESPACE tablespace_name STORAGE (INITIAL size K or M NEXT size K or M MINEXTENTS value MAXEXTENTS value PCTINCREASE value);
  • 21. Example • CREATE TABLE maha ( id NUMBER CONSTRAINT co_id PRIMARY KEY, name varchar(20)) TABLESPACE tp STORAGE ( INITIAL 7000 NEXT 7000 MINEXTENTS 1 MAXEXTENTS 5 PCTINCREASE 5);
  • 22. Table space • Most major RDBMSs have default settings for table sizes and table locations. • If you do not specify table size and location, then the table will take the defaults. • The defaults may be very undesirable, especially for large tables.
  • 23. Segments • The level of logical database storage above an extent is called a segment. A segment is a set of extents allocated for a certain logical structure. • the different types of segments include: 1. Data segments • Every table in an Oracle database has a single data segment 2. Index segments • Every index in an Oracle database has a single index segment holds all of its data
  • 24. 3. Temporary segments – Temporary segments are created by ORACLE. When a SQL statement needs a temporary work area to complete execution. When the statement finishes execution, the temporary segments extents are returned to the system for future use. 4. Rollback segments It records old values of data that was changed by each transaction.. “Undo Information”
  • 25. Rollback segments Rollback segments are areas in your database which are used to temporarily save the previous values when some updates occurred • have two main purposes : 1. If for one reason or another the user wants to cancel his/her update with a ROLLBACK statement, the former values are restored. This is possible only during the life of the transaction. If the user executes COMMIT instead, the values in the rollback segment are marked as invalidated and the change becomes permanent .
  • 26. 2. This is where other, concurrent sessions read the data when they access the changed tables before the transactions are committed. Note that if a SELECT starts on a table while a transaction is modifying the same table, the old value of the data will be read from a rollback segment - some queries take a pretty long time to run
  • 27. Advantages of COMMIT and ROLLBACK Statements • With COMMIT and ROLLBACK statements, you can: • Ensure data consistency • Preview data changes before making changes permanent
  • 28. State of the Data After ROLLBACK • Discard all pending changes by using the ROLLBACK statement: • Data changes are undone. • Previous state of the data is restored. • Locks on the affected rows are released. DELETE FROM copy_emp; 22 rows deleted. ROLLBACK; Rollback complete
  • 30. description statement Ends the current transaction by making all pending data changes permanent COMMIT Marks a savepoint within the current transaction SAVEPOINT name ends the current transaction by discarding all pending data changes ROLLBACK ROLLBACK TO SAVEPOINT rolls back the current transaction to the specified savepoint, thereby discarding any changes created after the savepoint to which you are rolling back. If you omit the TO SAVEPOINT clause, the ROLLBACK statement rolls back the entire transaction. As savepoints are logical, there is no way to list the savepoints you have created. ROLLBACK TO SAVEPOINT name
  • 31. Rolling Back Changes to a Marker • Create a marker in a current transaction by using the SAVEPOINT statement. • Roll back to that marker by using the ROLLBACK TO SAVEPOINT statement. • Example:UPDATE........... SAVEPOINT update_done; Savepoint created. INSERT........... ROLLBACK TO update_done; Rollback complete.
  • 32. State of the Data After COMMIT • Data changes are made permanent in the database. • The previous state of the data is permanently lost. • All users can view the results. • All savepoints are erased.
  • 33. Committing Data • Make the changes. DELETE FROM employees WHERE employee_id = 99999; 1 row deleted. INSERT INTO departments VALUES (290, 'Corporate Tax', NULL, 1700); 1 row inserted. • Commit the changes. COMMIT; Commit complete.
  • 34. Data blocks • An ORACLE database's data is stored in data blocks. • One data block corresponds to a specific number of bytes of physical database space on disk.‘ • A data block size is specified for each ORACLE database when the database is created. • A database uses and allocates free database space in ORACLE data blocks
  • 35. Data blocks • Each Data Block consists of: header, free space and row data – Header - contains information about the data block contents, and is made up of three separate subsections: the block header, the table directory, and the row directory – Free space - is empty space that the block retains in case users update the data within the data block, and the updated data occupies more storage space than the original data – Row Data – stores actual data values
  • 37. Physical Database Structure • An ORACLE database's physical structure is determined by the operating system files that constitute the database. • The files of a database provide the actual physical storage for database information
  • 38. Physical Database Structure 1. Datafiles – contain the actual data values 2. Redo log files - record all changes made to data, including both uncommitted and committed changes. 3. Control files - contain information about the database tablespaces, datafiles, redo log files, and the current state of the database Ex. Database name
  • 39. Data Files • Every ORACLE database has one or more physical data files. • A database's data files contain all the database data. • The data of the logical database structures such as tables and indexes is physically stored in the data files allocated for a database.
  • 40. Data files • A Data file can be associated with only one database • One or more datafiles are explicitly created for each tablespace to physically store the data of all logical structures
  • 41. Redo log files • The primary function of the redo log is to record all changes made to data. • The information in a redo log file is used only to recover the database from a system or media failure that prevents database from being written to database's data files.
  • 42. Control Files • Every ORACLE database has a control file. A control file records the physical structure of the database. For example, it contains the following types of information: - database name - names and locations of a database's data files and redo log files - time stamp of database creation • You should create two or more copies of the control file during database creation.