1.新建表空间(本地管理方式)
(1)普通表空间
create tablespace autotbs
datafile '/oracle/autotbs01.dbf' size 100M
extent management local autoallocate;
(2)临时表空间
create temporary tablespace lmtemp
tempfile 'I:\oracle\oradata\lmtemp01.dbf' size 50M reuse
extent management local uniform size 136K;
要创建本地管理方式的 临时表空间,必须使用create temporary tablespace,并且区的分配管理方式
只能是uniform,而不能是autoallocate,这样才能保证不会在临时段中产生过多的存储碎片。
2.设置表空间脱机联机
alter tablespace autotbs offline;
alter tablespace autotbs online;
3.设置表空间为只读/可读可写
alter tablespace autotbs read only;
alter tablespace autotbs read write;
4.添加表空间数据文件
为普通表空间添加数据文件:
alter tablespace autotbs add datafile '/oracle/autotbs02.dbf' size 100M
为临时表空间添加数据文件:
alter tablespace lmtemp add tempfile '/oracle/lmtemp02.dbf' size 10M reuse;
5.改变数据文件大小
(1)设置数据文件为自动增长方式
-----------------
alter tablespace autotbs
add datafile '/oracle/autotbs02.dbf' size 50M
autoextend on next 5M maxsize 100M;
-----------------
alter database datafile '/oracle/autotbs01.dbf'
autoextend on next 1M maxsize 200M;
(2)手工改变数据文件的大小
alter database datafile '/oracle/autotbs01.dbf' resize 500M;
6.改变数据文件可用性
alter database datafile '/oracle/autotbs01.dbf' online/offline;
7.删除表空间
drop tablespace autotbs including contents and datafiles;
8.查询
(1)查询表空间的默认存储参数
select tablespace_name,initial_extent,next_extent,min_extents,max_extents,pct_increase
from dba_tablespaces;
(2)查询表空间的数据文件信息
select file_name,blocks,tablespace_name
from dba_data_files;
(3)查询数据文件的基本信息
select name,file#,Rfile#,status,bytes,checkpoint_change# lase_scn
from v$datafile;
(4)查询数据文件的自动增长方式
select tablespace_name,file_name,autoextensible from dba_data_files;