实践Oracle表空间

block size maxsize remark
2048 8191M  
4096 16383M  
8192 32767M 32G比32767M大1M
16384 65535M  

数据表空间(Permanent和undo)

表空间至少有一个datafile

1
2
3
-- 新建表空间(固定大小)
-- logging
create tablespace "IDXSPACE01" logging datafile '/oraData1/oradata/itsdb/idx01.dbf' size 5G  online;
1
2
3
-- 新建表空间(自动扩展有上限)
-- nologging
create tablespace "DATSPACE" nologging datafile '/oradata/ctsdb/ctsdb/datspace.dbf' size 1024M AUTOEXTEND ON NEXT 512M MAXSIZE 10G online;
1
2
-- 新建表空间(自动扩展无上限)
create tablespace "DATSPACE" nologging datafile '/oradata/ctsdb/ctsdb/datspace.dbf' size 1024M AUTOEXTEND ON NEXT 512M MAXSIZE unlimited online;
1
2
-- 删除表空间
DROP TABLESPACE "DATSPACE01"
1
2
-- 添加datafile
alter tablespace "DATSPACE01" add datafile '/oradata/ctsdb/ctsdb/datspace01_01.dbf' size 10G autoextend on next 512M maxsize 32767M;
1
2
-- 删除datafile
ALTER TABLESPACE "DATSPACE01" DROP datafile '/oradata/ctsdb/ctsdb/datspace01_1.dbf'

临时表空间(Temporary)

1
alter tablespace "TEMP" add tempfile '/u01/reportdb/temp02.dbf' size 2048M;

查询表空间

TABLESPACE_NAME BLOCK_SIZE

INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS MAX_SIZE PCT_INCREASE

MIN_EXTLEN STATUS CONTENTS LOGGING FORCE_

EXTENT_MANAGEMENT ALLOCATION_TYPE PLUGGE SEGMENT_SPAC DEF_TAB_COMPRESS

RETENTION BIGFIL PREDICATE_EVAL ENCRYP COMPRESS_FOR

1
2
3
4
SELECT * FROM DBA_TABLESPACES;
SELECT TABLESPACE_NAME, BLOCK_SIZE, MAX_SIZE FROM DBA_TABLESPACES;
-- 查询用户默认表空间
SELECT DEFAULT_TABLESPACE,USERNAME FROM DBA_USERS WHERE USERNAME='EASACCT';