-bash-3.2$ more tablespace.sh
#!/bin/bash
clear scr
val1=`sqlplus -S / as sysdba<<EOF
set line 200 pagesize 200
col "File Name" for A50
select
fs.tablespace_name "Tablespace",
(df.totalspace - fs.freespace) "Used MB",
fs.freespace "Free MB",
df.totalspace "Total MB",
round(100 * (fs.freespace / df.totalspace)) "Pct. Free",
df.file_name "File Name",
df.autoextensible "Is Extensible",
df.MaxSize "Max Size MB"
from
(select
tablespace_name, file_name, autoextensible,
round((maxbytes) / 1024/1024) MaxSize,
round(sum(bytes) / 1024/1024) TotalSpace
from
dba_data_files
group by
tablespace_name, file_name, autoextensible, maxbytes
) df,
(select
tablespace_name,
round(sum(bytes) / 1024/1024) FreeSpace
from
dba_free_space
group by
tablespace_name
) fs
where
df.tablespace_name = fs.tablespace_name
order by 5 desc ;
EOF`
echo "Tablespace size is: $val1"
#!/bin/bash
clear scr
val1=`sqlplus -S / as sysdba<<EOF
set line 200 pagesize 200
col "File Name" for A50
select
fs.tablespace_name "Tablespace",
(df.totalspace - fs.freespace) "Used MB",
fs.freespace "Free MB",
df.totalspace "Total MB",
round(100 * (fs.freespace / df.totalspace)) "Pct. Free",
df.file_name "File Name",
df.autoextensible "Is Extensible",
df.MaxSize "Max Size MB"
from
(select
tablespace_name, file_name, autoextensible,
round((maxbytes) / 1024/1024) MaxSize,
round(sum(bytes) / 1024/1024) TotalSpace
from
dba_data_files
group by
tablespace_name, file_name, autoextensible, maxbytes
) df,
(select
tablespace_name,
round(sum(bytes) / 1024/1024) FreeSpace
from
dba_free_space
group by
tablespace_name
) fs
where
df.tablespace_name = fs.tablespace_name
order by 5 desc ;
EOF`
echo "Tablespace size is: $val1"
Output of the Script:
Tablespace size is:
Tablespace Used MB Free MB Total MB Pct. Free File Name Is Max Size MB
------------------------------ ---------- ---------- ---------- ---------- -------------------------------------------------- --- -----------
USERS 1 4 5 80 /u01/app/oracle/oradata/prim/users01.dbf YES 32768
UNDOTBS1 11 19 30 63 /u01/app/oracle/oradata/prim/undotbs01.dbf YES 32768
SYSAUX 544 36 580 6 /u01/app/oracle/oradata/prim/sysaux01.dbf YES 32768
SYSTEM 704 6 710 1 /u01/app/oracle/oradata/prim/system01.dbf YES 32768
No comments:
Post a Comment