ORACLE-基础六(TABLESPACE AND DataFiles)
2015-04-02 14:59
531 查看
Tablespaces & DataFiles
Oracle stores data logically in tablespaces and physically in data filesTablespaces:
1.Can belong to only one dataase at a time
2. Consist of one or more data files
3. Are further divied into locgical units of starage
Data files:
1.Can belong to only one tablespace and one database
2. Are a repository for schema object data
Types of Tablespaces
1.SYSTEM tablespacea. Created with the database
b.Contains the data dictionary
c.Contains the SYSTEM undo segment
2.Non-SYSTEM tablespace
a.Separate segmets
b.Eases space administration
c.Controls amount of space allocated to a user
also types : permanent, undo , temporary
Space Mgmt in Tablespaces
1.Locally maaged tablespace:a.Free extents are managed in the tablespace
b.Bitmap is used to record free extents.
c. Each bit corresponds to a block or group of blocks.
d. Bit value indicates free or used.
2.Dictionary-managed tablespace:
a. Free extents are managed by the data dictionary.
b.Appropriate tables are updated when extents are allocated or dellocated
推荐使用local Managed TS
Dictionary-Managed TS
1.Extents are managed in the data dictionary2.Each segment stored in the tablespace can have a different storage clause.
3.Coalescing is required
CREATE TABLESPACE userdata DATAFILE 'xxxx.dbf' SIZE 500M EXTENT MANAGEMENT DICTIONARY DEFAULT STORAGE(initial 1M NEXT 1M PCTINCREASE 0)
</pre><h1 class="sql" name="code">Locally Managed Tablespace</h1><span style="font-size:18px;"></span><pre class="sql" name="code">1.Reduce contention on data dictionary tables
2.No undo generated when space allocation or deallocation occurs
3.No coalescing required
<pre class="sql" name="code">CREATE TABLESPACE userdata DATAFILE '/u01/oradata/userdata01.dbf' SIZE 500M EXTENT MANAGMENT LOCAL UNIFORM SIZE 128K
Migrating a DM SYSTEM TS
Migrate a dictionary manged SYSTEM tablespace to locally managed:DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_TO_LOCAL('SYSTEM');
Undo Tablespace
1.Used to store undo segments2.Cannot contain any other objects
3.Extents are locally namaged
4.Can only use the DATAFILE and EXTENT MANAGEMENT clauses
CREATE UNDO TABLESPACE undo1 DATAFILE '/u01/oradata/undo01.dbf' SIZE 40M
Temporary Tablespaces
1.Used for sort operations2. Can be shared by multiple users
3.Cannot contain any permanent objects
4.Locally managed extents recommended
CREATE TEMPORARY TABLESPACE temp TEMPFILE '/u01/oradta/temp01.dbf' SIZE 20M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 4M;
Create temporary tablespace mytemp tempfile '/u01/oradata/wilson/mytemp01.dbf' size 100M extent management local;
Restrictions
Defualt tmporary tablespaces cannot be:1.Dropped until after a new default is made available
2.Taken Offline
3.Altered to a permanent tablespace
Read-Only Tablespaces
Use the following command to place a tablespace in read-only mod:ALTERTABLESPACE userdata READ ONLY
1.Causes a checkpoint
2.Data available only for read operations
3.Objects can be dropped from tablespace
Taking a Tablespace Offline
1.Not available for data access2.Tablespaces that cannot be aken offline:
a.SYSTEM tablespace
b.Tablespaces with active undo segments
c.Default temporary tablespace
3.To take a tablespace offline:
ALTER TABLESPACE userdata OFFLINE
4.To bring a tablespace online:
ALTER TABLESPACE userdata ONLINE
Resizeing a Tablespace
A tablespace can be resized by :1. Change the size of a data file:
a.Automatically using AUTOEXTEND
b.Manually using ALTER DATABASE
2.Adding a data file using ALTER TABLESPACE
Enable Automatic Extension
1.Can be resized automatically with the following commands:a.CREATE DATABASE
b.CREATE TABLESPACE
c.ALTER TABLESPACE ... ADD DATAFILE
b.Example:
CREATE TABLESPACE user_data DATAFILE '/u01/oradata/userdata01.dbf' SIZE 200M AUTOEXTEND ON
NEXT 10M MAXSIZE 500M
c.Query the DBA_DATA_FILES view to determine whether AUTOEXTEND is enabled
Manually Resizing Date File
1.Manually increase or decrease a data file size using ALTER DATABASE2.Resizeing a data file adds more space without adding more data files
3.Manual resizeing of a data file reclaims unused space in database
Example:
ALTER DATABASE DATAFILE '/u01/oradata/userdaa0.dbf' RESIZE 200M
Adding Data Files to a TS
Increases the space allocated to a tablespace by adding additional data filesAdd DATAFILE clause is used to add a data file
Example:
ALTER TABLESPACE user_data ADD DATAFILE '/u01/oradata/userdata03.dbf' SIZE 200M
Methods for Moving DF
1.ALTER TABLESPACEa.TABLESPACE must be offline.
b. Target data files must exist
ALTER TABLESPACE userdate RENAME DATAFILE '/u01/oradata/allan/1.dbf' TO '/u01/radata/allan/2.dbf'
2.ALTER DATABASE
a. Database must be mountd
b.Targe datafile must exit
ALTER DATABASE RENAME FILE '/u01/oradata/system01.dbf' TO '/u01/oradata/system02.dbf'
Dropping Tablespaces
1.You cannot drop a tablespace if it:a.Is the SYSTEM tablespace
b. Has active segments
2.INCLUDING CONTENTS drops the segments
3.INCLUDING CONTENTS AND DATAFILES deletes data files
4.CASCADE CONSTRAINTS drops all referential integrity constraints.
DROP TABLESPACE userdata INCLUDING CONTENTS AND DATAFILES;
GEt Tablespace Information
Obtaining tablespace and data file information can be obtained by querying the following:1.Tablespace information:
a.DBA_TABLESPACES
b.v$TABLESPACE
2.Data file information:
a.DBA_DATA_FILES
b.V$DATAFILE
3.Temp file information:
a. DBA_TEMP_FILES
b.V$TEMPFILE
相关文章推荐
- Oracle Study Note : Tablespace and Data Files
- drop tablespace TEST including contents and datafiles;
- Oracle Tablespace & Datafiles--Oracle表空间--应用实例(1)
- Chapter 08–Maintaining Tablespace and Data files
- drop tablespace XXX including contents and datafiles cascade constraints数据文件无法删除
- oracle datafile and tablespace
- Oracle Tablespace & Datafiles--Oracle表空间--应用实例(2)
- manage tablespace and datafile
- oracle tablespace datafile入门1
- Managing Tablespaces and Data Files
- redolog and tablespace and datafile
- Oracle create tablespace 、create user and so on
- Making User-Managed Backups-17.4、Making User-Managed Backups of Online Tablespaces and Datafiles
- Oracle:Create tablespace and move table to another tablespace
- All about oracle smallfile and bigfile tablespace
- Oracle OMF--------Tablespace creation is a snap with Oracle Managed Files
- Data Guard Physical Standby - Managing temporary tablespace tempfiles (文档 ID 1514588.1)
- Fundamental I 08 Maintaining Tablespaces and Data Files
- Making User-Managed Backups-17.3、Making User-Managed Backups of Offline Tablespaces and Datafiles
- oracle create user and create tablespace