Oracle table space full processing

View table space situation

1. --View table space

select username, default_tablespace, temporary_tablespace from dba_users;


2.--View the table space size

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


3.--View table space usage

SELECT a.tablespace_name "表空间名",total "表空间大小",free "表空间剩余大小",
(total - free) "表空间使用大小",total / (1024 * 1024 * 1024) "表空间大小(G)",
free / (1024 * 1024 * 1024) "表空间剩余大小(G)",
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)",
round((total - free) / total, 4) * 100 "使用率 %"
FROM (SELECT tablespace_name, SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name ;

View the file location stored in the table space

select file_name , tablespace_name from dba_data_files;
select * from dba_data_files;

To expand the table space, you can refer to the following methods:

Method 1: Manually reset and increase the data file size of the table space tbsk

alter database datafile '/opt/oracle/oradata/ora11g/system.dbf' resize 20G;
alter database datafile 'F:\app\Administrator\oradata\DGR\DATAFILE\O1_MF_SYSAUX_FKD2052J_.DBF' resize 20G;


Method 2: Set the table space data file to automatically grow (this method is not recommended)

alter database datafile '/opt/oracle/oradata/ora11g/system.dbf' autoextend on next 10M maxsize unlimited;
alter database datafile '文件路径' autoextend on next 100m maxsize 2000G;
  一个表空间数据库文件最大可以扩展到32G。


Method 3: Add a new data file (this method is recommended)

alter tablespace 表空间名称 add datafile ‘新增表空间文件地址’ size 2048M;
alter tablespace system add datafile '/opt/oracle/oradata/ora11g/system2.dbf' size 10G autoextend off;

 

Table space automatic expansion

Turn on automatic expansion

SQL> alter database datafile 'E:\ORADATA\GSDOORDB\SAMPLE2_1.DBF' autoextend on;

SQL> alter database datafile 'E:\ORADATA\GSDOORDB\SAMPLE1_1.DBF' autoextend on next 5M maxsize 500M;

Turn off automatic expansion

SQL> alter database datafile 'E:\ORADATA\GSDOORDB\SAMPLE2_1.DBF ' autoextend off;

Guess you like

Origin blog.csdn.net/springlan/article/details/106416615