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.
Ad

More Related Content

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

Myth busters - performance tuning 103 2008
Myth busters - performance tuning 103 2008Myth busters - performance tuning 103 2008
Myth busters - performance tuning 103 2008
paulguerin
 
Oracle Database Introduction
Oracle Database IntroductionOracle Database Introduction
Oracle Database Introduction
Chhom Karath
 
12. oracle database architecture
12. oracle database architecture12. oracle database architecture
12. oracle database architecture
Amrit Kaur
 
SQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - AdvancedSQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - Advanced
Tony Rogerson
 
Postgres db performance improvements
Postgres db performance improvementsPostgres db performance improvements
Postgres db performance improvements
Mahesh Chopker
 
Data warehouse physical design
Data warehouse physical designData warehouse physical design
Data warehouse physical design
Er. Nawaraj Bhandari
 
Aioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_features
AiougVizagChapter
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
enosislearningcom
 
An Introduction To Oracle Database
An Introduction To Oracle DatabaseAn Introduction To Oracle Database
An Introduction To Oracle Database
Meysam Javadi
 
ORACLE ARCHITECTURE
ORACLE ARCHITECTUREORACLE ARCHITECTURE
ORACLE ARCHITECTURE
Manohar Tatwawadi
 
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaaPerfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Cuneyt Goksu
 
Oracle Database Architecture
Oracle Database ArchitectureOracle Database Architecture
Oracle Database Architecture
Hamzaakmak1
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
Rajesh Gunasundaram
 
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum
 
Introduction to oracle database (basic concepts)
Introduction to oracle database (basic concepts)Introduction to oracle database (basic concepts)
Introduction to oracle database (basic concepts)
Bilal Arshad
 
People soft basics
People soft basicsPeople soft basics
People soft basics
technicalguru
 
Oracle 10g Introduction 1
Oracle 10g Introduction 1Oracle 10g Introduction 1
Oracle 10g Introduction 1
Eryk Budi Pratama
 
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerGeek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
IDERA Software
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsOracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
Yogiji Creations
 
Data Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptxData Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptx
TusharAgarwal49094
 
Myth busters - performance tuning 103 2008
Myth busters - performance tuning 103 2008Myth busters - performance tuning 103 2008
Myth busters - performance tuning 103 2008
paulguerin
 
Oracle Database Introduction
Oracle Database IntroductionOracle Database Introduction
Oracle Database Introduction
Chhom Karath
 
12. oracle database architecture
12. oracle database architecture12. oracle database architecture
12. oracle database architecture
Amrit Kaur
 
SQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - AdvancedSQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - Advanced
Tony Rogerson
 
Postgres db performance improvements
Postgres db performance improvementsPostgres db performance improvements
Postgres db performance improvements
Mahesh Chopker
 
Aioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_features
AiougVizagChapter
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
enosislearningcom
 
An Introduction To Oracle Database
An Introduction To Oracle DatabaseAn Introduction To Oracle Database
An Introduction To Oracle Database
Meysam Javadi
 
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaaPerfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Cuneyt Goksu
 
Oracle Database Architecture
Oracle Database ArchitectureOracle Database Architecture
Oracle Database Architecture
Hamzaakmak1
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
Rajesh Gunasundaram
 
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum
 
Introduction to oracle database (basic concepts)
Introduction to oracle database (basic concepts)Introduction to oracle database (basic concepts)
Introduction to oracle database (basic concepts)
Bilal Arshad
 
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerGeek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
IDERA Software
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsOracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
Yogiji Creations
 
Data Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptxData Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptx
TusharAgarwal49094
 

Recently uploaded (20)

How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Ad

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.