如图,使用wabacus配置出来的查询oracle表结构的页面.
实际就是从数据字典中查询出结果,展示出来.
其中主键字段会加粗显示.
页面效果如下(其中的浮层效果请见
http://hilltop.iteye.com/blog/1678368)
sql语句如下
SELECT dense_rank() over(ORDER BY a.table_name) AS seq, a.table_name,
d.comments AS table_comments, a.column_id, a.column_name,
a.data_type || nvl2(a.char_col_decl_length,
'(' || a.char_col_decl_length || ')',
'') AS data_type,
DECODE(a.nullable,'N','N',NULL) as nullable, c.comments AS col_comments,
nvl2((SELECT i2.column_name
FROM user_ind_columns i2, user_indexes i1
WHERE i2.index_name = i1.index_name
AND i2.table_name = i1.table_name
AND i1.table_type = 'TABLE'
AND i1.uniqueness = 'UNIQUE'
AND i2.table_name = a.table_name
AND i2.column_name = a.column_name),'Y',NULL) AS is_pk
FROM user_tab_columns a, user_tables b, user_col_comments c, user_tab_comments d
WHERE a.table_name = b.table_name
AND a.table_name = c.table_name(+)
AND a.column_name = c.column_name(+)
AND a.table_name = d.table_name(+)
ORDER BY b.table_name, a.column_id
page的配置如下
<!-- oracle10g 查询表结构 2012-9-25 -->
<page xmlns="http://www.wabacus.com" id="query_oracle_schema" js="/js/mouseover.js" css="/css/mouseover.css">
<report id="report1" title="Oracle Table Schema" dataexport="richexcel|word"
pagesize="30|60|-1" navigate="${navigatepagesizepage1.report3.navigate}" >
<display>
<col column="seq" label="序号" rowgroup="true" width="6%"></col>
<col column="table_name" label="表名" filter="true" rowgroup="true" width="12%" align="left"></col>
<col column="table_comments" label="表描述" width="2%" displaytype="optional"></col>
<col column="column_id" label="字段序号" width="6%" align="right"></col>
<col column="column_name" label="字段名" width="20%" align="left"></col>
<col column="data_type" label="类型" width="13%" align="left"></col>
<col column="is_pk" label="是否主键" width="6%" displaytype="optional" align="left"></col>
<col column="nullable" label="允许为空" width="6%" align="left"></col>
<col column="col_comments" label="字段描述" width="29%" align="left"></col>
</display>
<sql>
<value>
<![CDATA[
SELECT dense_rank() over(ORDER BY a.table_name) AS seq, a.table_name,
d.comments AS table_comments, a.column_id, a.column_name,
a.data_type || nvl2(a.char_col_decl_length,
'(' || a.char_col_decl_length || ')',
'') AS data_type,
DECODE(a.nullable,'N','N',NULL) as nullable, c.comments AS col_comments,
nvl2((SELECT i2.column_name
FROM user_ind_columns i2, user_indexes i1
WHERE i2.index_name = i1.index_name
AND i2.table_name = i1.table_name
AND i1.table_type = 'TABLE'
AND i1.uniqueness = 'UNIQUE'
AND i2.table_name = a.table_name
AND i2.column_name = a.column_name),'Y',NULL) AS is_pk
FROM user_tab_columns a, user_tables b, user_col_comments c, user_tab_comments d
WHERE a.table_name = b.table_name
AND a.table_name = c.table_name(+)
AND a.column_name = c.column_name(+)
AND a.table_name = d.table_name(+)
AND {#condition#}
ORDER BY b.table_name, a.column_id
]]>
</value>
<condition name="txt_table_name" label="表名">
<value>
<![CDATA[(a.table_name like '%#data#%' )]]>
</value>
<inputbox>
<typeprompt count="15">
<promptcol label="table_name" matchmode="2"></promptcol>
<datasource>select table_name from user_tables where table_name like '%#data#%'</datasource>
</typeprompt>
</inputbox>
</condition>
</sql>
<format>
<value>
<![CDATA[
//如果column属于主键,则加粗字体
if("Y".equals(is_pk)){
column_name="<b>"+column_name+"</b>";
}
if(table_comments!=null){//如果表描述不为空,则表描述以浮层展示
table_name="<div title='"+table_comments+"'>"+table_name+"</div>";
}
if(col_comments!=null){//如果字段描述不为空,则以浮层展示
col_comments="<div title='"+col_comments+"'>"+col_comments+"</div>";
}
]]>
</value>
</format>
</report>
</page>