import groovy.sql.Sql
sql = Sql.newInstance(
"jdbc:postgresql://localhost:5432/yourdb",
"postgres",
"postgres",
"org.postgresql.Driver")
query = """
select
pc.relname table_name,
round(pg_total_relation_size(pc.oid)/1024) as KBytes
from
pg_class pc
where
pc.relkind = 'r'
order by
2 desc
limit 30
"""
sql.eachRow(query){
// テーブル名とサイズ
println "${it.table_name},${it.KBytes}(KBytes)"
}
動作環境
groovy 1.7.4, JDK6 Update21, PostgreSQL8.4.4
0 件のコメント:
コメントを投稿