> select *from DBA_TABLESPACES where TABLESPACE_NAME ='TABLESPACENAME'; 查看表空间 > drop tablespace TABLESPACENAME including contents and datafiles cascade constraint; 删除表空间 > CREATE TABLESPACE TABLESPACENAME DATAFILE 'D:\APP\ADMINISTRATOR\ORADATA\oracle\TABLESPACENAME.DBF' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED; windows创建表空间 > CREATE TABLESPACE TABLESPACENAME DATAFILE '/u01/oracle/oradata/wlzy/ECMSSTATS.DBF' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED; linux创建表空间 表空间大小自动增长
数据库所有表空间使用率 > SELECT to_date(sysdate), Upper(F.TABLESPACE_NAME) "表空间名", D.TOT_GROOTTE_MB "表空间大小M)", D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间M)", To_char(Round(( D.TOT_GROOTTE_MB - F.TOTAL_BYTES ) / D.TOT_GROOTTE_MB * 100, 2), '990.99') || '%' "使用率", F.TOTAL_BYTES "空闲空间(M)", F.MAX_BYTES "最大块(M)" FROM (SELECT TABLESPACE_NAME, Round(Sum(BYTES) / ( 1024 * 1024 ), 2) TOTAL_BYTES, Round(Max(BYTES) / ( 1024 * 1024 ), 2) MAX_BYTES FROM SYS.DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) F, (SELECT DD.TABLESPACE_NAME, Round(Sum(DD.BYTES) / ( 1024 * 1024 ), 2) TOT_GROOTTE_MB FROM SYS.DBA_DATA_FILES DD GROUP BY DD.TABLESPACE_NAME) D WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME ORDER BY 1;
表空间大小 > select b.file_name 物理文件名, b.tablespace_name 表空间, b.bytes/1024/1024 大小M, (b.bytes-sum(nvl(a.bytes,0)))/1024/1024 已使用M, substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) 利用率 from dba_free_space a,dba_data_files b where a.file_id=b.file_id group by b.tablespace_name,b.file_name,b.bytes order by b.tablespace_name
|