oracle增加表空间大小
第一步:创建表空间
create tablespace TEST datafile '/u01/app/oracle/oradata/orcl/example01.dbf' size 100M autoextend on next 50M maxsize unlimited;
第二步:查看表空间的名字及文件所在位置:
select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name
第三步:增大所需表空间大小:
方法一:
alter database datafile '表空间位置'resize 新的尺寸
例如:
alter database datafile '/u01/app/oracle/oradata/orcl/example01.dbf' resize 4000m
对于oracle数据库的表空间,除了用手动增加大小外,还可以增加数据文件等方式扩展表空间大小。
方法二:增加数据文件个数
alter tablespace 表空间名称add datafile '新的数据文件地址' size 数据文件大小
例如:
alter tablespace ESPS_2008 add datafile '/u01/app/oracle/oradata/orcl/example01.dbf' size 1000m
方法三:设置表空间自动扩展。
alter database datafile '数据文件位置' autoextend on next 自动扩展大小maxsize 最大扩展大小
例如:
alter database datafile '/u01/app/oracle/oradata/orcl/example01.dbf' autoextend on next 100m maxsize 10000m
第四步:查询表空间使用情况:
--查看表空间使用情况
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