oracle扩展表空间
阅读原文时间:2023年07月09日阅读:1

select tablespace_name,
file_id,
file_name,
round(bytes / (1024 * 1024), 0) total_space
from sys.dba_data_files
order by tablespace_name;

2.  指定表空间查看数据文件目录

select name from v$datafile where ts# in (select ts# from v$tablespace where name='USERS');

SELECT 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;

4.  指定表空间查看使用率

select 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 and b.tablespace_name='USERS' group by b.tablespace_name,b.file_name,b.bytes order by b.tablespace_name;

5.  查询表空间信息

select username,default_tablespace,t.* from dba_users t

select a.tablespace_name,
a.bytes / 1024 / 1024 "sum MB",
(a.bytes - b.bytes) / 1024 / 1024 "used MB",
b.bytes / 1024 / 1024 "free MB",
round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "used%"
from (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes, max(bytes) largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes - b.bytes) / a.bytes) desc;

7.  查看剩余空间

select group_number,name,total_mb,free_mb from v$asm_diskgroup;

表空间最大为:32GB
alter database datafile '表空间位置' resize 新的尺寸

操作:
指定的路径由表空间位置所在
alter tablespace USERS add datafile '/u01/odata/db/ausers13.dbf' size 30G autoextend on;

例:
+DATA/icdc/datafile/data.268.902365317

扩展空间
alter database datafile '+DATA' size 20G;

温馨提示:本文由自己记录,仅作参考,出了问题概不负责。。。。。

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器