JDBC元数据操作,DatabaseMetaData接口详解链接描述
MySQL中表的字段信息查询–information_schema.COLUMNS-- 链接描述
<select id="selectDimTabCols" parameterType="java.lang.String" resultType="com.table.column.pojo.DimTabCols">
select
column_name as colName,
column_comment as colDesc,
data_type as typeName,
character_maximum_length as colLength,
numeric_precision as colPrecision,
is_nullable as colNullable,
column_key as keyFlag,
ordinal_position as colSeq
from information_schema.columns
where table_name = #{tabName}
</select>
<update id="updateTabCols">
update dim_tab_cols set col_name =
<foreach collection='tabColsList' item='item' index='index' separator=' ' open='case col_Id' close='end'>
when #{item.colId} then #{item.colName}
</foreach>
where col_id in
<foreach collection='colIds' item='item' index='index' separator=',' open='(' close=')'>
#{item}
</foreach>
</update>
for (int i = 0; i < tabColsList.size(); i++) {
if("NO".equals(tabColsList.get(i).getColNullable())){
createdColList.get(i).setIsNullable("0");
}else {
createdColList.get(i).setIsNullable("1");
if(null == tabColsList.get(i).getKeyFlag()){
createdColList.get(i).setColumnKey("0");
}else if("PRI".equals(tabColsList.get(i).getKeyFlag())){
createdColList.get(i).setColumnKey("1");
}else {
createdColList.get(i).setColumnKey("0");
}
}*/
}
打开App,阅读手记