Oracle Database Administration Database files Logical database structures.

Slides:



Advertisements
Similar presentations
CHAPTER 4 Tablespaces and Datafiles. Introduction After installing the binaries, creating a database, and configuring your environment, the next logical.
Advertisements

11 Copyright © Oracle Corporation, All rights reserved. Managing Tables.
The Architecture of Oracle
Module 2: Database Architecture
5 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
School of Computing and Management Sciences © Sheffield Hallam University The slowest task in any record retrieval is reading from disk (It can be 500.
Page Footer Keed Education Oracle Database Administration Basic Copyright 2009 Keed Education BV Version Concept.
Primer on Structure& Storage Analysis Primer on Structure & Storage Analysis This presentation is supposed to give a simple and brief overview for storage.
Basic Storage Concepts and Settings
Data archival using Partitioning and Partition Maintenance O/o the A.G.(A&E)-II NagpurMaharashtra.
Introduction to Structured Query Language (SQL)
Harvard University Oracle Database Administration Session 2 System Level.
Harvard University Oracle Database Administration Session 5 Data Storage.
Introduction to Structured Query Language (SQL)
Backup and Recovery Part 1.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Oracle Database Administration
CHAPTER 11 Large Objects. Need for Large Objects Data type to store objects that contain large amount of text, log, image, video, or audio data. Most.
IT Database Administration Section 03. Tablespaces and the DBA  Important for DBAs – logical units of database storage Made up of physical operating-system.
9/11/2015ISYS366 - Week051 ISYS366 – Week 5-6 Database Tuning - User and Rollback Data Spaces, Recovery, Backup.
Oracle Database Architecture An Oracle server: –Is a database management system that provides an open, comprehensive, integrated approach to information.
Database Administration TableSpace & Data File Management
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
7202ICT Database Administration Lecture 7 Managing Database Storage Part 2 Orale Concept Manuel Chapter 3 & 4.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 7 Basic Table Management.
16 Copyright © 2004, Oracle. All rights reserved. Undo Management.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Introduction to Oracle. Oracle History 1979 Oracle Release client/server relational database 1989 Oracle Oracle 8 (object relational) 1999.
Oracle 10g Database Administrator: Implementation and Administration Chapter 7 Basic Table Management.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
7 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
Week 3 Lecture 2 Basic Storage Concepts and Settings.
14 Copyright © 2006, Oracle. All rights reserved. Tuning Block Space Usage.
5 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
Week 4 Lecture 2 Advanced Table Management. Learning Objectives  Create tables with large object (LOB) columns and tables that are index-organized 
Database Storage Structures
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Harvard University Oracle Database Administration Session 6 Object Storage.
6 Copyright © 2007, Oracle. All rights reserved. Managing Database Storage Structures.
Oracle 10g Database Administrator: Implementation and Administration Chapter 5 Basic Storage Concepts and Settings.
Managing Tablespaces and Data Files
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
IT Database Administration Section 07. Space Management Managing Space: An Introduction  Organizing database storage is a major responsibility.
G Copyright © 2006, Oracle. All rights reserved. Miscellaneous Topics.
Creating Indexes on Tables An index provides quick access to data in a table, based on the values in specified columns. A table can have more than one.
Chap 5. Disk IO Distribution Chap 6. Index Architecture Written by Yong-soon Kwon Summerized By Sungchan IDS Lab
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Oracle Architecture - Structure. Oracle Architecture - Structure The Oracle Server architecture 1. Structures are well-defined objects that store the.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Physical Database Structure .
What is Oracle ? Oracle is a relational database management system. It is a management system which uses the relational data model. In the relational data.
Select Operation Strategies And Indexing (Chapter 8)
8 Copyright © Oracle Corporation, All rights reserved. Managing Tablespaces and Data files.
1 Chapters 19 and 20  Ch. 19: By What Authority? Users Roles Grant and revoke Synonyms  Ch. 20: Changing the Oracle Surroundings Indexes Clusters Sequences.
9 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
Table spaces.
Database structure and space Management
Database Tuning - User and Rollback Data Spaces, Recovery, Backup
Storage Structure and Relationships
Oracle 10g Database Administrator: Implementation and Administration
Database structure and space Management
Physical Database Structure .
Introduction To Oracle 10g
Storage Structure and Relationships
Managing Tablespaces and Data Files
ISYS366, Oracle Disk Internals
Database administration
Presentation transcript:

Oracle Database Administration Database files Logical database structures

Data storage structures Physical structures: –Data files – disk files that contain database data Logical database structures include: –Tablespaces –Segments –Extents –Blocks

Data files Data files: –all database data is stored there –data files can automatically extend if required (the AUTOEXTEND clause) –one or more datafile form a logical unit of database storage called a tablespace –Oracle does not write modified data immediately, if the database is not closed properly, datafiles can contain incorrect data

Data files Data file: –Can be regular file on a hard drive (any hard drive in a computer) (typical case) –Can be a raw device (on Unix systems). Oracle writes data directly to disk with minimum overhead) –Can use external hard drives (can be used when configuring Real Application Cluster)

Tablespaces Tablespace: –basic logical storage unit – table data, index data is stored in a tablespace –consists of one or more datafile (each datafile belongs to exactly one tablespace) –there is no relationship between tablespaces and schemas: objects from one schema can exist in different tablespaces one tablespace can contain objects from different schemas –to create tablespace: CREATE TABLESPACE new_tablespace DATAFILE 'C:\...\new_tab.dbf' SIZE 10MC:\ –to put table in a tablespace: CREATE TABLE (id number) TABLESPACE new_tablespace;

Tablespaces Each database has special tablespaces: –SYSTEM tablespace – should only be used by system objects –SYSAUX tablespace – Oracle managed internal data –temporary tablespace – used by temporary tables and temporary data – sorting, groupping –undo tablespace – used to store undo data required for transaction rollback

Tablespaces Each user has default tablespace and temporary tablespace: –CREATE USER xxx IDENTIFIED BY yyy DEFAULT TABLESPACE zzz TEMPORARY TABLESPACE vvv; Default tablespace is where user objects are created unless otherwise specified Temporary tablespace is where temporary objects will be stored: –user’s temporary table data –temporary space required by operations like sorting, grouping, distinct

Tablespaces Tablespace size is the size of all its datafiles Objects assigned to a tablespace store their data in tablespace datafiles: –single object can span multiple datafiles belonging to the same tablespace –when all tablespace datafiles become full Oracle: tries to extend a datafile created with the AUTOEXTEND clause with size smaller than MAXSIZE reports an error if no file has AUTOEXTEND clause or files already have their MAXSIZE

Adding more space to the database To add more space do one of: –add new file to existing tablespace: ALTER TABLESPACE name ADD DATAFILE ‘path’ SIZE 1G AUTOEXTEND OFF –add new tablespace: CREATE TABLESPACE name DATAFILE ‘path’ SIZE 1G AUTOEXTEND ON NEXT 1G MAXSIZE 10G –change size of existing datafile: ALTER DATABASE DATAFILE ‘path’ SIZE 4G

Adding more space to the database Adding datafile to a tablespace

Adding more space to the database Adding new tablespace

Adding more space to the database Increasing datafile size

Putting objects in a tablespace When creating object: –CREATE TABLE table_name (column definitions) TABLESPACE tablespace_name –CREATE INDEX index_name ON table_name(column_list) TABLESPACE tablespace_name When moving object: –ALTER TABLE table_name MOVE TABLESPACE tablespace_name –ALTER INDEX index_name REBUILD TABLESPACE tablespace_name When the table is moved all indexes become unusable –unusable index needs to be rebuild before it can be used: ALTER INDEX index_name REBUILD

Putting objects in a tablespace

Temporary tablespaces Creating temporary tablespace requires different syntax: CREATE TEMPORARY TABLESPACE temp_demo TEMPFILE 'temp01.dbf' SIZE 5M AUTOEXTEND ON; Information about regular data files is stored in V$DATAFILE view Information about temporary files is stored in V$TEMPFILE view

Segments Segment: –is a space allocated for a specific data structure, e.g. each table has its own data segment, each index has index segment –segment is always stored in a single tablespace (possibly in multiple files from that tablespace) –each segment is divided into extents and extents are divided into data blocks

Segments Example: –Table with 2 indexes has 1 table segment, and 2 index segments –Each of those segments can be stored in a different tablespace Information about segments is in the USER_SEGMENTS and DBA_SEGMENTS views

Extents Extent: –is a contiguous space in a data file –when adding data to a segment Oracle tries to fill existing extents, if all extents are full – Oracle adds another extent –extents of a segment may not be contiguous on disk – multiple extents usually mean that table data is fragmented

Data blocks Data block: –smallest unit of data allocation –database block size is usually between 2KB – 32KB

Segments, extents and data blocks

Data blocks Data block: –smallest unit of data allocation –database block size is usually between 2KB – 32KB

Free space in a data block Oracle inserts multiple rows into single data block (if row size is smaller than block size) Sometimes a row will occupy more than one block: –if a row size is larger than data block size – data chaining –if a row is inserted small and then updated and there is no space left in the data block – data migration Data chaining is unavoidable, Oracle tries to prevent data migration

Data migration example CREATE TABLE test1 (id NUMBER, text VARCHAR2(4000)); INSERT INTO test1 (id, text) VALUES (1, NULL); INSERT INTO test1 (id, text) VALUES (2, NULL); INSERT INTO test1 (id, text) VALUES (3, NULL); INSERT INTO test1 (id, text) VALUES (4, NULL); INSERT INTO test1 (id, text) VALUES (5, NULL); -- all rows are inserted into single data block UPDATE test1 SET text = ‘some long text......’ WHERE id IN (1, 2, 4, 5, 6); -- there is no space left in the row for all these rows, -- Oracle performs data migration

Data migration When performing data migration Oracle: –moves row data to another data block –keeps pointer to the new data block in the original data block Scanning multiple data blocks to get one row decreases performance – data migration should be prevented Two parameters are provided to control free space in the block: PCTFREE and PCTUSED

PCTFREE Example: –CREATE TABLE test (id NUMBER) PCTFREE 20; PCTFREE – amount of space in the block reserved for future updates of the inserted rows

PCTUSED Example: –CREATE TABLE test (id NUMBER) PCTFREE 20 PCTUSED 40; PCTUSED – once free space in the block drops below PCTFREE, oracle uses free space in the block only for updates until amount of used space drops below PCTUSED

PCTUSED and PCTFREE

Extent allocation Extent allocation strategy is important for performance and free space management: –Many small extents decrease performance – segment is fragmented –Too large extents waste space Extents within a tablespace can be managed: –LOCALLY – (recommended) information about extents is stored in tablespace itself –DICTIONARY – information about extents is stored in data dictionary in SYSTEM tablespace

Extent allocation -- Default extent management CREATE TABLESPACE tsh_data_1 DATAFILE 'c:\Oracle\Oradata\TSH1\tsh101.dbf' SIZE 50M; -- Explicit dictionary extent management CREATE TABLESPACE tsh_data_2 DATAFILE 'c:\Oracle\Oradata\TSH1\tsh201.dbf' SIZE 50M EXTENT MANAGEMENT DICTIONARY; -- Local extent management using autoallocate CREATE TABLESPACE tsh_data_3 DATAFILE 'c:\Oracle\Oradata\TSH1\tsh301.dbf' SIZE 50M EXTENT MANAGEMENT LOCAL AUTOALLOCATE; -- Local extent management using uniform extents CREATE TABLESPACE tsh_data_4 DATAFILE 'c:\Oracle\Oradata\TSH1\tsh401.dbf' SIZE 50M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;