查看各表空间的使用情况 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) "percent_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
select * from dba_data_filesorder by tablespace_name, file_name; select tablespace_name,dba_tablespaces.* from dba_tablespaces
表真实占用的空间
select OWNER, t.segment_name, t.segment_type, sum(t.bytes / 1024 / 1024/1024) USED_G from dba_segments t where t.owner LIKE ‘%ODS%‘ AND SEGMENT_NAME NOT LIKE ‘BIN$%‘ group by OWNER, t.segment_name, t.segment_type order by OWNER, USED_G desc;
--1、查看表空间的名称及大小 select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size from dba_tablespaces t, dba_data_files d where t.tablespace_name = d.tablespace_name group by t.tablespace_name; --2、查看表空间物理文件的名称及大小 select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name;
alter tablespace {表空间名字} add datafile ‘物理数据文件路径‘ SIZE 『初始大小M』 AUTOEXTEND ON NEXT 『自动扩展大小M』 alter tablespace SDK_TB add datafile ‘/oradata/ORA11G/sdk_tb2.dbf‘ size 1000m autoextend on next 200m
如果datafile加错到表空间,执行删除
Alter tablespace SDK_TB drop datafile ‘/oradata/ORA11G/a_tb04.dbf‘; 或者 alter database datafile ‘/oradata/ORA11G/a_tb04.dbf‘ offline drop;
查看临时表空间
select * from dba_temp_files where tablespace_name = ‘DEV_TEMP2‘ order by tablespace_name, file_name;
添加临时表空间文件
alter tablespace DEV_TEMP2 add tempfile ‘/data/phonedb/datafile/dev_temp3.dbf‘ size 1000m autoextend on next 200m
修改用户默认表空间
alter user user_name default tablespace dev_tb; alter user user_name temporary tablespace dev_temp;
查看数据文件是否有数据:
只需查看数据文件中是否包含extent段。如果有extent(索引段,数据段)段,则说明数据文件中有数据。
使用dba_extents视图和dba_data_files视图进行连接查询。
select t.file_name,t1.owner,t1.segment_name,t1.segment_type,t1.tablespace_name from dba_data_files t,dba_extents t1 where t.file_id=t1.file_id and file_name=‘你要查询的数据文件路径‘;
原文地址:https://www.cnblogs.com/lcword/p/11775782.html
时间: 2024-11-18 21:42:50