第八章Maintaining Tablespaces & Data Files
locally-managed tablespace
每一个数据文件都存储一个bitmap位图,用来管理extents。一个bit表示一个extent,bit为1代表该extent被使用,bit为0表示该extent未被使用。
分配extent时不需要再进行查询,所以分配extent速度很快,同时可以在表空间的基础上进行并行分配。
Oracle9i之后使用DBCA创建的system表空间是locally-managed,从而后面创建的表空间都是locally-managed。
Undo Tablespace
①存储undo段
②不能包含其他对象
③extents是locally-managed
④只能使用datafile和extent management语句
create undo tablespace undo1 datafile ‘/u01/oradata/undo01.dbf’ size 40M;
Temporary Tablespace
①进行分类操作时使用
②多用户共同使用
③不能包含永久对象
④建议使用locally-managed
create temporary tablespace temp tempfile ‘/u01/oradata/temp01.dbf’ size 20M extent management local uniform size 4M;
如果system表空间是locally-managed,至少得定义一个默认的temporary tablespace,locally-managed system表空间不能作为默认的临时表空间。
如果system表空间是dictionary-managed,同时没有定义一个默认的temporary tablespace,则system表空间用来做默认临时表空间。但是在alert.log文件中会有告警信息,提示建议创建一个临时表空间。
Default Temporary Tablespace
①数据库全局的默认临时表空间
②减少使用system表空间存储临时数据
③通过create database和alter database创建
数据库创建完成后添加默认temporary tablespace
首先创建一个临时表空间,然后将该表空间指定为默认临时表空间
create temporary tablespace mytemp tempfile ‘/u01/oradata/wilson/mytemp01.dbf’ size 20M extent management local;
alter database default temporary tablespace mytemp;
查询数据库当前默认temporary tablespace
select * from database_properties;
select tablespace_name,contents,extent_management from dba_tablespaces;
默认临时表空间限制
在创建新的默认临时表空间生效之前无法删除当前的默认临时表空间
默认临时表空间无法离线
默认临时表空间无法更改成永久表空间
临时表空间可以有多个,但默认临时表空间只能有一个