mysql 系统表的作用



mysql 的系统表记录了所有数据库表(包括视图的定义语句)的字段列,顺序,类型等等,知道这些的话可以做些抽取模板淫荡的操作吧 嘿嘿 


  1. public void shuaxinglb() {
  2. try {
  3. PrintWriter out = ServletActionContext.getResponse().getWriter();
  4. eqmsService.saveOrupdateBySql("delete from glb", null);
  5. List<User> users = eqmsService.findAll("from User", null);
  6. eqmsService
  7. .saveOrupdateBySql(
  8. "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';",
  9. null);
  10. for (User user : users) {
  11. eqmsService
  12. .saveOrupdateBySql(
  13. "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=? );",
  14. new Object[] { user.getUserId(), user.getUserId()});
  15. }
  16. eqmsService.saveOrupdateBySql("delete from user_glb where user_glb.lieming not in(select glb.lieming from glb where glb.biaoming=user_glb.biaoming);", null);
  17. eqmsService.saveOrupdateBySql(
  18. "update user_glb set zwm=lieming where zwm ='';", null);
  19. out.print("aaa");
  20. } catch (IOException e) {
  21. // TODO Auto-generated catch block
  22. e.printStackTrace();
  23. }
  24. }

posted on 2017-03-21 16:56  signheart  阅读(1218)  评论(0编辑  收藏  举报

导航