import groovy.sql.Sql
sql = Sql.newInstance(
"jdbc:oracle:thin:@localhost:1521:orcl",
"system",
"system",
"oracle.jdbc.driver.OracleDriver")
query = """
select ddf.file_name as filename,
round(ddf.bytes/1024/1024, 2) as filesize,
round(dfs.bytes/1024/1024, 2) as freesize,
round((ddf.bytes - dfs.bytes)/ddf.bytes, 2)*100 as used
from dba_data_files ddf
join (select file_id, sum(bytes) as bytes
from dba_free_space
group by file_id) dfs
on (dfs.file_id = ddf.file_id)
order by ddf.file_name
"""
// データファイル毎の使用率
sql.eachRow(query){
println("${it.filename}, ${it.filesize}MB, \
${it.freesize}MB, ${it.used}%")
}
動作環境
groovy 1.7.4, JDK6 Update21, Oracle11g R2
0 件のコメント:
コメントを投稿