这几天一直数据库插入不了,最后是数据库表空间满了。
---查询表空间文件最大值已经当前值
select f.* from dba_data_files f
---查看数据库表空间大小,使用大小的sql
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
//因为上面这个查询是查询当前数据库大小,所以如果满了情况下会出现99%多的使用率,但是用下面的语句扩容后,也一直不会显示太太一直在99%多的使用率,因为数据库扩容是每50MB来扩的,不够用就扩50Mb,直到MaxBety,需要使用
select f.* from dba_data_files f
来查询最大表空间容量。
增加表空间最大值得方法
alter database datafile
'/opt/oracle/oradata/orcl/HdccDatabase.dbf' autoextend on next 50M
maxsize 19500M;