oracle表空间Managing Tablespace & Data Files(一)

2014-11-24 17:06:29 · 作者: · 浏览: 0

oracle表空间Managing Tablespace & Data Files
[sql]
一、Objectives
Define the purpose of tablespaces and data files(定义的表空间和数据文件的目的)
Create tablespaces www.2cto.com
Manage tablespaces
Create and manage tablespaces using Oracle Managed Files(OMF)
Obtain tablespace information (获取表空间信息)
二、Tablespaces & Data Files
Oracle stores data logically in tablespaces and physically in data files
Tablespaces
--Can belong to only on database at a time
--
Data files
三、Storage Hierarchy summary存储层次结构总结
logical
Database->Tablespace->segment->extent->oracle data block
Database->Schema
Physical
Datafile->OS block
一个Tablespace 对应多个Data file
一个ORacle data block 对应多个 OS black 是os block的倍数
四、Types of Tablespaces
1、SYSTEM tablespace
--Create with the database
--Contains the data dicationary
--Contains the SYSTEM undo segment
2、Non-System tablespace
--Separate segments
--Eases space administration 简化空间管理
--Controls amount of space allocated to a user
www.2cto.com
另外三种划分(permanent,undo,temporary)
五、查看表空间相关信息
1、查看表空间
select * from v$tablespace;
2、查看表空间包含数据
select file_name,tablespace_name from dba_data_files;
六、Create Tablespaces
create tablespace paul datafile
'/u01/app/oracle/product/10.2.0/oradata/oamis/paul01.dbf' size 20m;
七、两种方式
dictionary-mangage tablespace 中央集中式
a locally managed 独立式 (9版本都采用这种方式,但还是兼容以前的方式)
9i以后如果system 表空间是 locally managed 管理,那新建的都是
将Dictionary-mangage方式转换为locally managed
DBMS_SPACE_ADMIN.TABLESPCAE_MIGRATE_TO_LOCAL('system')(共有7步工作)
八、Undo Tablespace(用于回滚操作)
1、Used to store undo segments
2、Cannot contain any other objects
3、Extents are locally managed
4、Can only use the DataFile and Extent management clauses
www.2cto.com
create undo tablespace undo1
datafile '/u01/app/oracle/oradata/undo01.dbf' size 40M;
九、Temporary Tablespace(最好单独指定)
1、used for sort operation
2、can be shared by multiple user
3、cannot contain any permanent objects(不能包含永久信息)
4、Locally managed extents recommended (推荐使用locally 方式)
5、
Create temporary tablespace temp
tempfile '/u01/app/oracle/oradata/temp01.dbf' size 20M
extent management local uniform size 4M
1、创建 数据库的时候指定Temporary tablespace
2、创建临时表空间,然后修改
①、创建
create temporary tablespace mytemp1
tempfile '/u01/app/oracle/product/10.2.0/oradata/oamis/mytemp01.dbf' size 100M
extent management local;
②、修改
alter database default temporary tablespace mytemp1;
Temporary Tablespace Restriction
1、Dropped until after a new default is made available 不能删除
2、Taken offline 不能离线
3、Altered to a permanent tablespace 不能改变为永久表空间
十、Read-only Tablespace
1、Causes a checkpoint (导致了一个检查点)
2、Data available only for read operation
3、Object can be dropped from tablespace
(System Tablespace 不可能read-only,drop 的时候只是drop 数据字典的东西)
4、测试上面三点 www.2cto.com
①、创建表空间
create tablespace shanxi datafile
'/u01/app/oracle/product/10.2.0/oradata/oamis/shanxi.dbf' size 20m
extent management local uniform size 128k;
②、创建用户,默认表空间是shanxi
create user fc i