oralce获取当前的表空间已经各个表空间的使用情况

------查看oracle有哪些表空间
SELECT total.tablespace_name,
Round(total.gb, 2) AS total_gb,
Round(total.gb - free.gb, 2) AS used_gb,
Round(free.gb, 2) AS free_gb,
Round(( 1 - free.gb / total.gb ) * 100, 2)
|| ‘%’ AS used_pct
FROM (SELECT tablespace_name,
Sum(bytes) / 1024 / 1024 / 1024 AS gb
FROM dba_free_space
GROUP BY tablespace_name) free,
(SELECT tablespace_name,
Sum(user_bytes) / 1024 / 1024 / 1024 AS gb
FROM dba_data_files
GROUP BY tablespace_name) total
WHERE free.tablespace_name = total.tablespace_name
ORDER BY used_pct desc;

----查询对应表空间的使用情况
select owner,segment_name,sum(bytes)/1024/1024/1024 GB from dba_segments where tablespace_name=‘TBS_TXNDATA’ group by owner,segment_name order by 3 desc;

-----清除日志表数据
truncate table XXXXX

select ‘alter table ‘||table_owner||’.’||table_name||’ drop partition ‘||partition_name||’;’ from dba_tab_partitions where partition_name!=‘PART_1’ and table_name like ‘CPS_ACCOUNT_ENTRY%’;

https://www.cnblogs.com/jianshuai520/p/9766970.html
https://jingyan.baidu.com/article/414eccf67a35a96b431f0ac2.html

你可能感兴趣的:(随笔)