import groovy.sql.Sql
sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")
query = """
select
index_name,
ordinal_position,
column_name,
index_type_name
from
information_schema.indexes
order by
table_schema, table_name, index_name, ordinal_position
"""
// indexのカラムを一覧表示する
sql.eachRow(query){
println("index_name:${it.index_name}")
println("ordinal_position:${it.ordinal_position}")
println("column_name:${it.column_name}")
println("index_type_name:${it.index_type_name}")
println("-----")
}
動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)
0 件のコメント:
コメントを投稿