managing database storage structures

72
12 Copyright © 2004, Oracle. All rights reserved. Managing Database Storage Structures

Upload: ronna

Post on 16-Mar-2016

66 views

Category:

Documents


1 download

DESCRIPTION

Managing Database Storage Structures. Objectives. After completing this lesson, you should be able to do the following: Describe the uses of the SYSAUX tablespace Specify a default user tablespace Create bigfile tablespaces Create a default temporary tablespace - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Managing Database Storage Structures

12Copyright © 2004, Oracle. All rights reserved.

Managing Database Storage Structures

Page 2: Managing Database Storage Structures

12-2 Copyright © 2004, Oracle. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:• Describe the uses of the SYSAUX tablespace• Specify a default user tablespace• Create bigfile tablespaces• Create a default temporary tablespace• Create temporary tablespace groups• Rename tablespaces• Use the Redo Logfile Sizing Advisor

Page 3: Managing Database Storage Structures

12-3 Copyright © 2004, Oracle. All rights reserved.

SYSAUX Tablespace: Overview

• Auxiliary tablespace to the SYSTEM tablespace• Mandatory tablespace• Created at time of database creation• Same security attributes as SYSTEM tablespace

SYSTEM SYSAUX

PERMANENTREAD WRITEEXTENT MANAGEMENT LOCALSEGMENT SPACE MANAGEMENT AUTO

Page 4: Managing Database Storage Structures

12-4 Copyright © 2004, Oracle. All rights reserved.

SYSAUX Tablespace: Benefits

• Reduces the number oftablespaces to manage

• Load reduction on SYSTEM• Easier RAC management

...

SYSTEM

TOOLS

DRSYS

CWMLITE

ODM

SYSAUX

Page 5: Managing Database Storage Structures

12-5 Copyright © 2004, Oracle. All rights reserved.

SYSAUX Occupants

Occupant Original Oracle 9i LocationText, Ultra Search DRSYSIntermedia, spatial SYSTEMScheduler New in Oracle Database 10gOLAP CWMLITEXML DB XDB_RESINFOWorkspace Manager SYSTEMData Mining ODMServer Manageability Components New in Oracle Database 10gRecovery catalog TOOLSEM repository OEM_REPOSITORYAnalytical Workspace Object table SYSTEMLogMiner, Log Standby, streams SYSTEMStatspack User-specified

Page 6: Managing Database Storage Structures

12-6 Copyright © 2004, Oracle. All rights reserved.

Creating SYSAUX with DBCA

Page 7: Managing Database Storage Structures

12-7 Copyright © 2004, Oracle. All rights reserved.

Creating the SYSAUX Tablespace by Using CREATE DATABASE

CREATE DATABASEDATAFILE '/u0/datafiles/system1.dbf' SIZE 200MSYSAUX DATAFILE '/u0/datafiles/sysaux1.dbf' SIZE 300MDEFAULT TEMPORARY TABLESPACE stemp_tbs TEMPFILE '/u3/datafiles/stemp_tbs1.dbf' SIZE 60MUNDO TABLESPACE sundo_tbs DATAFILE '/u2/datafiles/sundo_tbs1.dbf' SIZE 100M;

Page 8: Managing Database Storage Structures

12-8 Copyright © 2004, Oracle. All rights reserved.

Altering the SYSAUX Tablespace

• You cannot alter mandatory attributes.• You must have the SYSDBA privilege.• Adding a data file:

• Taking the tablespace offline:

ALTER TABLESPACE sysaux ADD DATAFILE '/u0/datafiles/sysaux2.dbf' SIZE 200M ;

ALTER TABLESPACE sysaux OFFLINE;

Page 9: Managing Database Storage Structures

12-9 Copyright © 2004, Oracle. All rights reserved.

Managing the SYSAUX Tablespace

DROP TABLESPACE sysaux;

ALTER TABLESPACE sysaux RENAME TO auxiliary;

Data file transferSYSAUX

Page 10: Managing Database Storage Structures

12-10 Copyright © 2004, Oracle. All rights reserved.

Using EM to View SYSAUX Occupants

Page 11: Managing Database Storage Structures

12-11 Copyright © 2004, Oracle. All rights reserved.

Relocating SYSAUX Occupants with EM

Page 12: Managing Database Storage Structures

12-12 Copyright © 2004, Oracle. All rights reserved.

Relocating SYSAUX Occupants with SQL

SELECT OCCUPANT_NAME, SCHEMA_NAME, MOVE_PROCEDUREFROM V$SYSAUX_OCCUPANTS;

SELECT OCCUPANT_NAME, SPACE_USAGE_KBYTESFROM V$SYSAUX_OCCUPANTS;

• Monitor space usage of SYSAUX occupants:

• Determine which procedure to use to move occupants from SYSAUX:

Page 13: Managing Database Storage Structures

12-13 Copyright © 2004, Oracle. All rights reserved.

Relocating SYSAUX Occupants with SQL (continued)

EXEC WKSYS.MOVE_WK('DRSYS');

EXEC WKSYS.MOVE_WK('SYSAUX');

• Move SYSAUX occupants to the DRSYS tablespace:

• Move occupants back to the SYSAUX tablespace:

Page 14: Managing Database Storage Structures

12-14 Copyright © 2004, Oracle. All rights reserved.

Locally Managed SYSTEM Tablespace

• Locally managed SYSTEM tablespace was supported beginning with Oracle9i, Release 2.

• The benefits of this feature include:– Better performance– Ease of administration

• A locally managed SYSTEM tablespace is of allocation type AUTOALLOCATE.

• If your database has a locally managed SYSTEM tablespace, some restrictions apply.

Page 15: Managing Database Storage Structures

12-15 Copyright © 2004, Oracle. All rights reserved.

Locally Managed SYSTEMTablespace Restrictions

A locally managed SYSTEM tablespace places the following restrictions on the database:• COMPATIBLE must be at least 9.2.0.• Cannot have read/write dictionary-managed

tablespaces• There must be a default temporary tablespace,

which cannot be the SYSTEM tablespace.• You cannot have rollback segments in a

dictionary-managed tablespace.

Page 16: Managing Database Storage Structures

12-16 Copyright © 2004, Oracle. All rights reserved.

Creating a Locally Managed SYSTEM Tablespace at Database Creation Time

To create a locally managed SYSTEM tablespace atdatabase creation time, you must specify the EXTENTMANAGEMENT LOCAL clause in the CREATE DATABASEstatement:

SQL> CREATE DATABASE 2 EXTENT MANAGEMENT LOCAL 3 DATAFILE SIZE 300M 4 UNDO TABLESPACE UNDO 5 DEFAULT TEMPORARY TABLESPACE TEMP;

Page 17: Managing Database Storage Structures

12-18 Copyright © 2004, Oracle. All rights reserved.

Migrating the SYSTEM Tablespaceto a Locally Managed Tablespace

• Use the DBMS_SPACE_ADMIN package:

• The locally managed SYSTEM tablespace restrictions are enforced by the migration procedure.

• Migration is possible only when the system is in restricted mode while all tablespaces other than SYSTEM, UNDO, and TEMP are in READ ONLY mode.

SQL> EXECUTE DBMS_SPACE_ADMIN. - 2 TABLESPACE_MIGRATE_TO_LOCAL('SYSTEM');

Page 18: Managing Database Storage Structures

12-19 Copyright © 2004, Oracle. All rights reserved.

Default Permanent Tablespace: Overview

• SYSTEM is the default permanent tablespace.• You can now change the default permanent

tablespace for nonsystem users.

SYSTEM

Nonsystem users

OEHR SH

System users

SYSTEMSYS OUTLN …

Default

Page 19: Managing Database Storage Structures

12-20 Copyright © 2004, Oracle. All rights reserved.

Using EM to Designate a Default Permanent Tablespace

Page 20: Managing Database Storage Structures

12-21 Copyright © 2004, Oracle. All rights reserved.

ALTER DATABASE DEFAULT TABLESPACE newusers;

Specifying a Default Permanent Tablespace by Using SQL

CREATE DATABASEDATAFILE '/u0/datafiles/system1.dbf' SIZE 200MSYSAUX DATAFILE '/u0/datafiles/sysaux1.dbf' SIZE 300MDEFAULT TABLESPACE users DATAFILE '/u1/datafiles/users1.dbf' SIZE 100M SEGMENT SPACE MANAGEMENT AUTO DEFAULT TEMPORARY TABLESPACE stemp_tbs TEMPFILE '/u3/datafiles/stemp_tbs1.dbf' SIZE 60MUNDO TABLESPACE sundo_tbs DATAFILE '/u2/datafiles/sundo_tbs1.dbf' SIZE 100M;

SELECT property_value FROM database_propertiesWHERE property_name = 'DEFAULT_PERMANENT_TABLESPACE';

Page 21: Managing Database Storage Structures

12-22 Copyright © 2004, Oracle. All rights reserved.

Oracle Managed Files (OMF): Overview

• Oracle database server creates and deletes files as needed for tablespaces, temporary files, online logs, and control files.

• You only need to specify the OS directory to be used for each file type.

• OMF and non-OMF files can coexist.• Benefits of using OMF:

– Reduces corruption caused by administrators– Reduces disk space consumed by obsolete files– Simplifies creation of test and development

databases– Makes development of portable applications easier

Page 22: Managing Database Storage Structures

12-24 Copyright © 2004, Oracle. All rights reserved.

Deciding to Use Oracle Managed Files

• Databases that are supported by the following:– A logical volume manager that supports striping/RAID and

dynamically extensible logical volumes– A file system that provides large, extensible files

• Low-end or test databases• Not supported with raw devices

Page 23: Managing Database Storage Structures

12-25 Copyright © 2004, Oracle. All rights reserved.

Defining the Location for Oracle Managed Files

• Default OS directory: DB_CREATE_FILE_DEST• Control files and online log files:

DB_CREATE_ONLINE_LOG_DEST_n• Two basic OMF configurations:

– All files in one file system directory (DB_CREATE_FILE_DEST)

– Data files and temporary files separated from log files and control files (DB_CREATE_FILE_DEST and DB_CREATE_ONLINE_LOG_DEST_n)

Page 24: Managing Database Storage Structures

12-26 Copyright © 2004, Oracle. All rights reserved.

Implementing OMF: Example

1. Set the initialization parameters:

2. Create a database:

Every data file and log file is initially 100 MB by default, auto-extensible, and of unlimited size.

DB_CREATE_FILE_DEST = '/u01/oradata/'DB_CREATE_ONLINE_LOG_DEST_1 = '/u02/oradata/'DB_CREATE_ONLINE_LOG_DEST_2 = '/u03/oradata/'

SQL> CREATE DATABASE;

Page 25: Managing Database Storage Structures

12-27 Copyright © 2004, Oracle. All rights reserved.

OMF File Names: Structure

• OMF file names comply with Optimal Flexible Architecture (OFA):– Control files o1_mf_%u_.ctl– Redo log files o1_mf_%g_%u_.log– Data files o1_mf_%t_%u_.dbf– Temporary data files o1_mf_%t_%u_.tmp

• With SQL commands, you can manipulate existing OMF files just as you manipulate normal files.

• To determine whether a database file is an OMF:– Review the alert.log file.– Observe the file name.

Page 26: Managing Database Storage Structures

12-29 Copyright © 2004, Oracle. All rights reserved.

Managing OMF Control Files:Database Creation

• If no CONTROL_FILES parameter is specified,Oracle database server uses (in order of precedence):– DB_CREATE_ONLINE_LOG_DEST_n– DB_CREATE_FILE_DEST

• If none of the above are specified, the default destination is used (non-OMF).

• After database creation, create a CONTROL_FILES entry in the initialization parameter file.

• If there is a CONTROL_FILES parameter specified, then the behavior is unchanged from previous releases.

Page 27: Managing Database Storage Structures

12-30 Copyright © 2004, Oracle. All rights reserved.

Impact of OMF on the CREATE CONTROLFILE Command

• If the DB_CREATE_… parameters are specified,then the created control file will be OMF.

• Create a CONTROL_FILES entry in the parameter file, unless you use a server parameter file.

• Supply file names in the DATAFILE clauseeven for existing OMF files.

• Depending on the [NO]RESETLOGS clause:– Supply log file name if using NORESETLOGS– Allow Oracle database server to create OMF redo

logs if using RESETLOGS

Page 28: Managing Database Storage Structures

12-32 Copyright © 2004, Oracle. All rights reserved.

Managing OMF Redo Log Files

• Add a complete group with ALTER DATABASE ADD LOGFILE (no file specification, initialization parameters are used):

• You continue to add or remove individual members by specifying full file names.

• If you drop a group, all corresponding OMF files are deleted at the OS level.

• Archived redo log files cannot be OMF files.

SQL> ALTER DATABASE ADD LOGFILE;

SQL> ALTER DATABASE ADD LOGFILE SIZE 10M;

Page 29: Managing Database Storage Structures

12-33 Copyright © 2004, Oracle. All rights reserved.

Managing OMF Tablespaces

SQL> ALTER SYSTEM SET 2 DB_CREATE_FILE_DEST='/oradata/';

• The CREATE TABLESPACE command no longer needs a DATAFILE clause:

• When you drop a tablespace, all OMF files are also deleted at the OS level.

• Add OMF files to a tablespace:

• Change the default directory dynamically:

SQL> CREATE TABLESPACE TBS1 [DATAFILE SIZE 200M];

SQL> ALTER TABLESPACE TBS1 ADD DATAFILE;

Page 30: Managing Database Storage Structures

12-35 Copyright © 2004, Oracle. All rights reserved.

OMF Examples

SQL> ALTER DATABASE ADD LOGFILE SIZE 400M;

SQL> ALTER DATABASE RECOVER DATAFILE 2 '/u03/oradata/pay/o1_mf_tbs1_2ixfh90q_.dbf';

SQL> ALTER TABLE emp ALLOCATE EXTENT (DATAFILE 2 '/u03/oradata/pay/o1_mf_tbs1_2ixfh90q_.dbf');

SQL> ALTER DATABASE CREATE DATAFILE 2 '/u03/oradata/pay/o1_mf_tbs1_sd84oqy9_.dbf' 3 AS NEW;

SQL> CREATE TABLESPACE tbs02 2 DATAFILE SIZE 300M, SIZE 300M;

Page 31: Managing Database Storage Structures

12-36 Copyright © 2004, Oracle. All rights reserved.

Bigfile Tablespaces: Overview

• A bigfile tablespace contains a single file.• Maximum file size ranges from 8 TB to 128 TB.• Tablespaces are logically equivalent to data files.

Database

Tablespace

SmallfileDatafile Bigfile Data

file

Page 32: Managing Database Storage Structures

12-38 Copyright © 2004, Oracle. All rights reserved.

Bigfile Tablespace Benefits

• Significantly increases the storage capacity• Simplifies data file management for large

databases by making tablespaces the main units of disk space administration

BFT 1 …

8 EB4 billionblocks

One-to-one mapping

BFT n

Page 33: Managing Database Storage Structures

12-40 Copyright © 2004, Oracle. All rights reserved.

Using Bigfile Tablespaces

• Only supported for locally managed tablespaces using automatic segment space management

• Use with logical volume managers or Automatic Storage Management (ASM)

• OMF provides complete data file transparency.

Database Block Size Recommended Maximum Number of Extents

2 KB 100,0004 KB 200,0008 KB 400,00016 KB 800,000

Page 34: Managing Database Storage Structures

12-42 Copyright © 2004, Oracle. All rights reserved.

Creating Bigfile Tablespaces

Page 35: Managing Database Storage Structures

12-43 Copyright © 2004, Oracle. All rights reserved.

SQL Statement Changes and Additions

• BIGFILE and SMALLFILE can be used to override the default tablespace type when creating a tablespace.

• New commands and options were added to perform data file operations on bigfile tablespaces without specifying a data file name.

• Specify file size in gigabytes and terabytes using the letters G and T, respectively.

Page 36: Managing Database Storage Structures

12-44 Copyright © 2004, Oracle. All rights reserved.

CREATE DATABASESET DEFAULT BIGFILE TABLESPACEDATAFILE '/u0/data/system.dbf' SIZE 200MSYSAUX DATAFILE '/u0/data/sysaux.dbf' SIZE 300MSMALLFILE DEFAULT TEMPORARY TABLESPACE stemp_tbs TEMPFILE '/u3/data/stemp_tbs1.dbf' SIZE 60MSMALLFILE UNDO TABLESPACE sundo_tbs DATAFILE '/u2/data/sundo_tbs1.dbf' SIZE 100M;

ALTER DATABASE SET DEFAULT BIGFILE TABLESPACE;

CREATE BIGFILE UNDO TABLESPACE bundo_tbsDATAFILE '/u1/data/bundo_tbs.dbf' SIZE 1G;

ALTER TABLESPACE users RESIZE 2G;

ALTER TABLESPACE users AUTOEXTEND ON ;

Specifying Bigfile Tablespaces in SQL Commands

Page 37: Managing Database Storage Structures

12-45 Copyright © 2004, Oracle. All rights reserved.

Viewing Information About Bigfile Tablespaces

SELECT property_valueFROM database_propertiesWHERE property_name='DEFAULT_TBS_TYPE';

SELECT tablespace_name, bigfile FROM DBA_TABLESPACES;

SELECT name, bigfile FROM V$TABLESPACE;

Page 38: Managing Database Storage Structures

12-46 Copyright © 2004, Oracle. All rights reserved.

Using DBVERIFY with Bigfile Tablespaces

Smallfile tablespace Bigfile tablespace

SFile1 SFile2

$dbv FILE=SFile1

$dbv FILE=SFile2

$dbv FILE=BFile1 START=1 END=10000

BFile1

$dbv FILE=BFile1 START=10001

Page 39: Managing Database Storage Structures

12-47 Copyright © 2004, Oracle. All rights reserved.

Modifying Configuration Parameters for Bigfile Tablespaces

DB_FILES

MAXDATAFILESControl files

Data files

Smallfiles Bigfiles

Page 40: Managing Database Storage Structures

12-48 Copyright © 2004, Oracle. All rights reserved.

Using the DBMS_UTILITY Package with Bigfile Tablespaces

DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE()

DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK()

• Functions are not needed with bigfile tablespaces:

• Bigfile tablespace file number is 1024.

Page 41: Managing Database Storage Structures

12-49 Copyright © 2004, Oracle. All rights reserved.

Migrating Objects to Bigfile Tablespaces

SMALLFILE tablespace BIGFILE tablespace

ALTER TABLE MOVE

CREATE TABLE AS SELECT

Data Pump

Page 42: Managing Database Storage Structures

12-50 Copyright © 2004, Oracle. All rights reserved.

Extended ROWID Format and Bigfile Tablespaces

OOOOOO FFF BBBBBB RRR

Smallfile tablespaces Bigfile tablespaces

OOOOOO LLL LLLLLL RRR

Data objectnumber

Relative filenumber

Data blocknumber

Rownumber

Data objectnumber

Encoded blocknumber

Rownumber

DBMS_ROWID.ROWID_BLOCK_NUMBER

Page 43: Managing Database Storage Structures

12-52 Copyright © 2004, Oracle. All rights reserved.

DBMS_ROWID Package Changes

SELECT DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID,'BIGFILE')FROM employees;

ROWID_BLOCK_NUMBER ROWID_RELATIVE_FNO

ROWID_INFO

TS_TYPE_IN

Page 44: Managing Database Storage Structures

12-53 Copyright © 2004, Oracle. All rights reserved.

Default Temporary Tablespace: Overview

• Specify a database-wide default temporary tablespace at database creation or at a later time.

• If you do not specify a default temporary tablespace at database creation:– SYSTEM is the default temporary tablespace– A warning is written to the alert.log file

• Users not explicitly assigned to a temporary tablespace are assigned to the default temporary tablespace.

Page 45: Managing Database Storage Structures

12-54 Copyright © 2004, Oracle. All rights reserved.

Obtaining Information About the Default Temporary Tablespace

SQL> SELECT property_value 2 FROM database_properties 3 WHERE property_name = 4 'DEFAULT_TEMP_TABLESPACE';

Query DATABASE_PROPERTIES to retrieve information about the current default temporary tablespace:

Page 46: Managing Database Storage Structures

12-55 Copyright © 2004, Oracle. All rights reserved.

Creating a Default Temporary Tablespaceat Database Creation Time

SQL> CREATE DATABASE db1 CONTROLFILE REUSE 2 LOGFILE 'log1.log' SIZE 10M 3 LOGFILE 'log2.log' SIZE 10M 4 DATAFILE 'df1.dbf' AUTOEXTEND ON 5 'df2.dbf' AUTOEXTEND ON 6 NEXT 10M MAXSIZE UNLIMITED 7 DEFAULT TEMPORARY TABLESPACE dts1 8 TEMPFILE 'dts_1.f' SIZE 60M 9 EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

Page 47: Managing Database Storage Structures

12-56 Copyright © 2004, Oracle. All rights reserved.

Altering the Default Temporary Tablespace

• Change the default temporary tablespacewith the ALTER DATABASE command:

• Users are automatically reassigned to the new default temporary tablespace.

SQL> ALTER DATABASE db1 2 DEFAULT TEMPORARY TABLESPACE dts2;

Page 48: Managing Database Storage Structures

12-57 Copyright © 2004, Oracle. All rights reserved.

Managing Default TemporaryTablespace Restrictions

• You cannot drop a default temporary tablespace until after a new one is made available.

• Altering the default temporary tablespace to a permanent tablespace is not allowed (except for the SYSTEM tablespace).

• You cannot take the default temporary tablespace offline.

Page 49: Managing Database Storage Structures

12-58 Copyright © 2004, Oracle. All rights reserved.

Temporary Tablespace Group: Overview

• Groups temporary tablespaces together• Characteristics:

– At least one temporary tablespace– Same namespace as tablespaces– Created implicitly on first assignment– No explicit deletion

Default tablespaceEXAMPLE …

Default temporary tablespace group TEMP

TablespaceTEMP1

TablespaceTEMPn

Page 50: Managing Database Storage Structures

12-59 Copyright © 2004, Oracle. All rights reserved.

Temporary Tablespace Group: Benefits

Enables a user to use multiple temporary tablespaces:• Same user in multiple sessions• One particular parallel operation

Temporary tablespace group TEMP

TablespaceTEMP1

TablespaceTEMP2

TablespaceTEMP3

Serial ParallelHRHR

Page 51: Managing Database Storage Structures

12-60 Copyright © 2004, Oracle. All rights reserved.

Creating Temporary Tablespace Groups

Page 52: Managing Database Storage Structures

12-61 Copyright © 2004, Oracle. All rights reserved.

Maintaining Temporary Tablespace Groups

Page 53: Managing Database Storage Structures

12-62 Copyright © 2004, Oracle. All rights reserved.

Using SQL to Create a Temporary Tablespace Group

CREATE TEMPORARY TABLESPACE temp1 TEMPFILE 'tmp1.f' SIZE 100M TABLESPACE GROUP group1;

CREATE TEMPORARY TABLESPACE temp2 TEMPFILE 'tmp2.f' SIZE 200M TABLESPACE GROUP group2;

CREATE TEMPORARY TABLESPACE temp3 TEMPFILE 'tmp3.f' SIZE 50M TABLESPACE GROUP '';

Page 54: Managing Database Storage Structures

12-63 Copyright © 2004, Oracle. All rights reserved.

ALTER TABLESPACE temp3 TABLESPACE GROUP group2;

ALTER TABLESPACE temp2 TABLESPACE GROUP '';

ALTER TABLESPACE temp1 TABLESPACE GROUP group2;

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE group2;

CREATE USER hr IDENTIFIED BY hr DEFAULT TABLESPACE TS1 TEMPORARY TABLESPACE group2;

ALTER USER hr TEMPORARY TABLESPACE group2;

Using SQL to Manage Temporary Tablespace Groups

Page 55: Managing Database Storage Structures

12-64 Copyright © 2004, Oracle. All rights reserved.

Obtaining Information About Temporary Tablespace Groups

SELECT group_name, tablespace_nameFROM DBA_TABLESPACE_GROUPS;

Page 56: Managing Database Storage Structures

12-65 Copyright © 2004, Oracle. All rights reserved.

Using Nonstandard Block Sizes

• Support for databases with multiple block sizes was introduced in Oracle9i.

• The benefits of this feature include:– Ability to maximize I/O performance– Ability to transport tablespaces between databases

with different block sizes• A database can be created with a standard block

size and up to four nonstandard block sizes.• Block sizes can have any power-of-two value

between 2 KB and 32 KB.

Page 57: Managing Database Storage Structures

12-66 Copyright © 2004, Oracle. All rights reserved.

Specifying the Standard Block Size

• Set at database creation time with the DB_BLOCK_SIZE parameter; cannot be changed without re-creating the database

• Used for SYSTEM and TEMPORARY tablespaces• DB_CACHE_SIZE specifies the size of the DEFAULT

buffer cache for standard block size:– Minimum size = one granule (4 MB or 16 MB)– Default value = 48 MB

Page 58: Managing Database Storage Structures

12-67 Copyright © 2004, Oracle. All rights reserved.

Specifying Nonstandard Block Sizes

• Configure additional caches with the following dynamic parameters:– DB_2K_CACHE_SIZE 2 KB blocks– DB_4K_CACHE_SIZE 4 KB blocks– DB_8K_CACHE_SIZE 8 KB blocks– DB_16K_CACHE_SIZE 16 KB blocks– DB_32K_CACHE_SIZE 32 KB blocks

• Notes:– DB_nK_CACHE_SIZE is not allowed if nK is the

standard block size.– Minimum size for each cache is one granule.

Page 59: Managing Database Storage Structures

12-68 Copyright © 2004, Oracle. All rights reserved.

Creating a NonstandardBlock Size Tablespace

SQL> CREATE TABLESPACE tbs_1 2 DATAFILE 'tbs_1.dbf' 3 SIZE 10M BLOCKSIZE 4K;

SQL> describe dba_tablespaces

Name Null? Type ------------------ -------- ------------ TABLESPACE_NAME NOT NULL VARCHAR2(30) BLOCK_SIZE NOT NULL NUMBER ...

Page 60: Managing Database Storage Structures

12-69 Copyright © 2004, Oracle. All rights reserved.

Renaming Tablespaces: Overview

Dictionary-managed

tablespace

Create newintermediatetablespace.

Contenttransfer

Droporiginal

tablespace.

Create newlocally managedtablespace withoriginal name.

Contenttransfer

Dropintermediatetablespace.

1.

2.

3.

4.

5.

6.

7.

A A A A A A

B BB

B B

RenameB to A

A

With renameWithout rename

Page 61: Managing Database Storage Structures

12-70 Copyright © 2004, Oracle. All rights reserved.

Renaming Tablespaces: Considerations

• You can rename permanent or temporary tablespaces.

• SYSTEM and SYSAUX tablespaces cannot be renamed.

• Tablespace to be renamed must have all of itsfiles online.

• Tablespace identifiers are not affected.• Data file headers of READ ONLY tablespaces are not

changed.• SPFILEs are automatically updated if necessary.

Page 62: Managing Database Storage Structures

12-71 Copyright © 2004, Oracle. All rights reserved.

Renaming Tablespaces

ALTER TABLESPACE sample RENAME TO example;

Page 63: Managing Database Storage Structures

12-72 Copyright © 2004, Oracle. All rights reserved.

Renaming Tablespaces: Best Practices

• Do not rely on naming conventions for data files.• Use to simplify the transportable tablespace

procedure.• Recovery using data file backups containing old

tablespace names is not an issue:– Although certain dictionary views may temporarily

diverge, this should not be regarded as a corruption.

– As long as you recover past the rename point, the database stays synchronized with the renamed tablespace.

Page 64: Managing Database Storage Structures

12-73 Copyright © 2004, Oracle. All rights reserved.

Proactive Tablespace Monitoring: Overview

• Server-generated alerts inform you that:– Tablespaces are running low on available space– Segments are running out of space

• Data gathering and reporting:– Historical tablespace disk space usage– Segment growth trend analysis

Page 65: Managing Database Storage Structures

12-74 Copyright © 2004, Oracle. All rights reserved.

Space Usage Monitoring of Tablespaces

• Read-only and offline tablespaces: Do not set up alerts.• Temporary tablespace: Threshold corresponds to space

currently used by sessions.• Undo tablespace: Threshold corresponds to space used

by active and unexpired extents.• Autoextensible files: Threshold is based on the

maximum file size.

MMON

85% warning

97% criticalCheck every 10 minutes

Alert

Alert Cleared

Cleared

Page 66: Managing Database Storage Structures

12-75 Copyright © 2004, Oracle. All rights reserved.

Edit Thresholds of Tablespace Space Usage

Page 67: Managing Database Storage Structures

12-76 Copyright © 2004, Oracle. All rights reserved.

Using the Edit Tablespace Page

Page 68: Managing Database Storage Structures

12-77 Copyright © 2004, Oracle. All rights reserved.

Using the Redo Logfile Size Advisor

• This advisor determines the smallest size of your online redo logs.

• Size is calculated to ensure that redo log switches do not drive checkpointing.

• FAST_START_MTTR_TARGET must be set.

Page 69: Managing Database Storage Structures

12-78 Copyright © 2004, Oracle. All rights reserved.

Invoking the Redo Logfile Size Advisor

Page 70: Managing Database Storage Structures

12-79 Copyright © 2004, Oracle. All rights reserved.

Viewing the Optimal Redo Log File Size

View Name V$INSTANCE_RECOVERY

Column Name OPTIMAL_LOGFILE_SIZE

Description This column shows the redo log file size in megabytes that is considered as minimal.

Page 71: Managing Database Storage Structures

12-80 Copyright © 2004, Oracle. All rights reserved.

Summary

In this lesson, you should have learned how to:• Describe the uses of the SYSAUX tablespace• Specify a default user tablespace• Create bigfile tablespaces• Create a default temporary tablespace• Create temporary tablespace groups• Rename tablespaces• Use the Redo Logfile Sizing Advisor

Page 72: Managing Database Storage Structures

12-81 Copyright © 2004, Oracle. All rights reserved.

Practice 12 Overview: Monitoring Storage Structures

This practice covers the following topics:• Managing tablespace space usage• Using the Redo Logfile Size Advisor