mysql 的系统表记录了所有数据库表(包括视图的定义语句)的字段列,顺序,类型等等,知道这些的话可以做些抽取模板淫荡的操作吧 嘿嘿
public void shuaxinglb() {
try {
PrintWriter out = ServletActionContext.getResponse().getWriter();
eqmsService.saveOrupdateBySql("delete from glb", null);
List<User> users = eqmsService.findAll("from User", null);
eqmsService
.saveOrupdateBySql(
"INSERT INTO `glb` (`biaoming`, `lieming`, `leixing`, `zwm`,`shunxu`,`display`) select TABLE_NAME,COLUMN_NAME,data_type ,COLUMN_COMMENT,ordinal_position,1 from information_schema.columns where table_schema='tzerp_db';",
null);
for (User user : users) {
eqmsService
.saveOrupdateBySql(
"INSERT INTO `user_glb` (user_id,`biaoming`, `lieming`, `leixing`,`zwm`,`shunxu`,`display`) select ?,`biaoming`, `lieming`, `leixing`, `zwm`,`shunxu`,`display` from glb g where lieming not in(select lieming from user_glb where biaoming=g.biaoming and user_id=? );",
new Object[] { user.getUserId(), user.getUserId()});
}
eqmsService.saveOrupdateBySql("delete from user_glb where user_glb.lieming not in(select glb.lieming from glb where glb.biaoming=user_glb.biaoming);", null);
eqmsService.saveOrupdateBySql(
"update user_glb set zwm=lieming where zwm ='';", null);
out.print("aaa");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}