Get the App
SLTechnology News&Howtos  ›  Database  › 

Use spool output csv format to view system tablespace usage

Shulou Source: shulou.com Published: 2022-06-01 10:11:40 11月15日 Update

SET SPOOL ON pre off entmap off

SET ECHO OFF

SET TRIMOUT OFF

Set feedback off

Set heading on

Set colsep

Set trimspool on

Set headsep off

Set numw 10

Set linesize 200

Set pagesize 10000

Col tablespace_name format a15

Col total_space format a10

Col free_space format a10

Col used_space format a10

Col used_rate format 99.99

Spool / home/oracle/test.csv

Select a.tablespaceName name. Totalroomspaceworthy Mb | |'m 'total_space,b.free_space_Mb | |' m'

Free_space,a.total_space_Mb-b.free_space_Mb | |'m 'used_space

(1-(b.free_space_Mb/a.total_space_Mb)) * 100 used_rate,a.total_blocks,b.free_blocks from

(select tablespace_name,sum (bytes) / 1024 plus 1024 total_space_Mb,sum (blocks) total_blocks from dba_data_files

Group by tablespace_name) a

(select tablespace_name, sum ((bytes) / 1024) free_space_Mb,sum (blocks) free_blocks from dba_free_space

Group by tablespace_name) b

Where a.tablespace_name=b.tablespace_name order by used_rate desc

Spool off

Note (SET ECHO OFF does not display start, @, @ @ and other execution script commands entered by the terminal, the result is not displayed in the terminal when SET TERMOUT OFF is in spool, and SET TRIMOUT OFF deletes trailing spaces)

The results are as follows:

For more Oracle highlights, please follow me:

Tags: Terminal result wonderful content command tail time more space script input situation format space system output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno NVidia Docker Microsoft