当前位置:   article > 正文

PowerDesigner导入SQL脚本生成带中文注释(comment)的ER图并保存为图片格式(含通用可执行vb脚本文件)_powerdesigner把sql生成er图

powerdesigner把sql生成er图

目录

1、安装数据库建模工具PowerDesigner 16.5

2、打开 PowerDesigner,选择反向工程

3、选择数据库类型

4、导入SQL脚本文件并生成数据库表模型

5、去掉Diagram画板黑色网格线(选做)

6、ER图常规显示(包含是否为Null及表名注释)

7、显示中文注释comment(含vb可执行脚本)

8、将生成的ER图保存为图片


1、安装数据库建模工具PowerDesigner 16.5

        数据库建模工具PowerDesigner 16.5的安装、汉化与扩展教程请参考:

数据库建模工具PowerDesigner 16.5的安装、汉化与扩展教程(超详细)_蓝多多的小仓库的博客-CSDN博客

2、打开 PowerDesigner,选择反向工程

        点击菜单 File------>Reverse Engineer ------>Database 

3、选择数据库类型

        Model name:数据库模型的名称
        DBMS:数据库管理系统,下拉选择数据库类型

4、导入SQL脚本文件并生成数据库表模型

        选择使用脚本文件,点击 Add Files 图标,选择需要导入的本地 SQL 脚本文件并导入

        到此,我们可以看到刚刚选择好的需要导入的 SQL 脚本文件列表,如果还需要选择,可重复步骤4;如果没有,点确定即可开始反向工程生成数据库表模型。

5、去掉Diagram画板黑色网格线(选做)

        点击工具栏的 Tools ------> Display Preferences 菜单项,在弹出来的 Display Preferences 界面中找到 General Settings ------>  General ------>  Diagram,然后取消勾选 “Show page delimiter” 选项,最后 OK 确定保存,即可。如图所示:

6、ER图常规显示(包含是否为Null及表名注释)

        Tools------>Display Preferences------>table,这里你需要显示什么就勾选即可。(注意:表名注释需要预先在sql语句中写出哦,例如:COMMENT ON TABLE "you_table" IS '你的表';

7、显示中文注释comment(含vb可执行脚本)

        1>先多选一列code(用于改为注释),步骤:Tools------>Display Preferences------>table------>Advances------>columns------>select------>勾选code------>OK------>确定

        2> 通过脚本修改表名注释,字段注释

        Tools------>Execute Commands------>Edit/Run Script...

        3>在弹框中输入代码并run

  1. Option Explicit
  2. ValidationMode = True
  3. InteractiveMode = im_Batch
  4. Dim mdl 'the current model
  5. 'get the current active model
  6. Set mdl = ActiveModel
  7. If (mdl Is Nothing) Then
  8. MsgBox "There is no current Model"
  9. ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
  10. MsgBox "The current model is not an Physical Data model."
  11. Else
  12. ProcessFolder mdl
  13. End If
  14. 'This routine copy name into code for each table, each column and each view
  15. 'of the current folder
  16. Private sub ProcessFolder(folder)
  17. Dim Tab 'running table
  18. for each Tab in folder.tables
  19. if not tab.isShortcut then
  20. if len(tab.comment) <> 0 then
  21. tab.name = tab.name
  22. 'tab.name = tab.comment&"["&tab.name&"]"
  23. end if
  24. On Error Resume Next
  25. Dim col 'running column
  26. for each col in tab.columns
  27. if len(col.comment) <>0 then
  28. col.name =col.comment
  29. end if
  30. On Error Resume Next
  31. next
  32. end if
  33. next
  34. end sub

        4>到此,我们就可以看到ER图中有中文注释这一列啦

8、将生成的ER图保存为图片

        Ctrl+A 将图表全部选中,点击Edit------>Export Image在保存类型中选择JPEG或PNG即可

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/635650
推荐阅读
  

闽ICP备14008679号