🔔🔔🔔好消息!好消息!🔔🔔🔔-my_content

如果您需要注册ChatGPT,想要升级ChatGPT4。凯哥可以代注册ChatGPT账号代升级ChatGPT4

有需要的朋友👉:微信号 kaigejava2022

使用PowerDesigner生成数据库设计文档

2024-05-20 16:19   396 浏览

第一步:将现有得数据表通过PowerDesigner导入sql脚本(同时保证注释不丢失及name code comment)

1:依次点击File->Reverse Engineer->Database...

48d3646119b7cc6b9e1c923c3885fef3.png

2.弹出弹窗对模型进行命名,同时在DBMS下拉选择框中需要选择自己对应的数据库类型,点击确定 

d5daf334cced87c0d7945987a7481aa4.png


3.新的弹窗,选中Using script files,再点击红圈中,选中你的sql脚本位置,点击确定

2c06cbc43115093dd5f68dcb5e24de32.png

 4,结果图

07fbde51ef93a767096cf148f9380b64.png

 5.如何让Name里面的值显示的是comment里面的值


在使用REVERSE ENGINEER从数据库反向生成PDM的时候,PDM中的表的NAME和CODE事实上都是CODE,为了把NAME替换为数据库中Table或Column的中文Comment,可以使用以下脚本:


在PowerDesigner中使用方法为:


PowerDesigner->Tools->Execute Commands->Edit/Run Scripts


复制一下代码,点击RUN

Option   Explicit     
    ValidationMode   =   True     
    InteractiveMode   =   im_Batch  
    Dim blankStr  
    blankStr   =   Space(1)  
    Dim   mdl   '   the   current   model    
        
    '   get   the   current   active   model     
    Set   mdl   =   ActiveModel     
    If   (mdl   Is   Nothing)   Then     
          MsgBox   "There   is   no   current   Model "     
    ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then     
          MsgBox   "The   current   model   is   not   an   Physical   Data   model. "     
    Else     
          ProcessFolder   mdl     
    End   If    
        
    Private   sub   ProcessFolder(folder)     
    On Error Resume Next    
          Dim   Tab   'running     table     
          for   each   Tab   in   folder.tables     
                if   not   tab.isShortcut   then     
                      tab.name   =   tab.comment    
                      Dim   col   '   running   column     
                      for   each   col   in   tab.columns     
                      if col.comment = "" or replace(col.comment," ", "")="" Then  
                            col.name = blankStr  
                            blankStr = blankStr & Space(1)  
                      else    
                            col.name = col.comment     
                      end if    
                      next     
                end   if     
          next    
        
          Dim   view   'running   view     
          for   each   view   in   folder.Views     
                if   not   view.isShortcut   then     
                      view.name   =   view.comment     
                end   if     
          next    
        
          '   go   into   the   sub-packages     
          Dim   f   '   running   folder     
          For   Each   f   In   folder.Packages     
                if   not   f.IsShortcut   then     
                      ProcessFolder   f     
                end   if     
          Next     
    end   sub


创建模板及导出见凯哥个人博客中:《使用PowerDesigner16.5 逆向数据库生成表结构或导出word文档二》这一篇文章





喜欢 0

评论