查询表空间使用情况及表空间扩容

1.查询表空间使用情况

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
		and f.tablespace_name = '表空间名称'
order  by 4 desc;

1.1数据文件查询

select * from dba_data_files t;

2.表空间扩容

添加TEST表空间
1.系统自动给数据文件命名

alter tablespace TEST add datafile '+SSDDG3' size 30G AUTOEXTEND off;
alter tablespace TEST add datafile '+SSDDG3' size 30G AUTOEXTEND off;
alter tablespace TEST add datafile '+SSDDG3' size 30G AUTOEXTEND off;

2.无系统自动命名

alter tablespace TEST add datafile '新数据文件名(全路径)' size 30G AUTOEXTEND off;

3.表空间及数据文件大小更改

1.表空间缩小
如原表空间大小2G,缩小至1G

alter tablespace TEST resize 1G;

2.数据文件扩大
数据文件大小扩大不能超过表空间大小

alter database datafile 'bdf文件路径' resize 1G;

4.查询临时表空间

查询表

--1.查询默认临时表空间
select * 
from database_properties t
where t.property_name = 'DEFAULT_TEMP_TABLESPACE';
--2.查询默认临时表空间的大小
select t.tablespace_name,
       t.bytes) / ( 1024 * 1024 ) file_size,
       t.AUTOEXTENSIBLE
from dba_temp_files t;
--3.查询默认临时表空间使用情况
select t.tablespace_name,
       t.current_users,
       t.total_blocks,
       t.used_blocks,
       t.free_blocks
from v$sort_segment t;

用户及表空间删除

1. 在oracle中,可以使用“drop user 用户名称 cascade;”命令来删除指定用户
2. 使用“DROP TABLESPACE 表空间名 INCLUDING CONTENTS AND DATAFILES;”
	命令来删除指定表空间。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值