当前位置: 首页 > news >正文

PowerDesigner使用小总结

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

前言

总结powerdesigner使用技巧,如取消name和code的联动,去掉双引号等,方便中国用户使用

自己使用的PowerDesigner版本为16.5

基础

  • 去掉SQL中的双引号

    按照图片圈出来的部分操作

    3bec83a4ce95df6bd5fc377c967f50315e6.jpg

    修改配置

    8bb1762cb3d92db60635686d29dc1e02cf3.jpg

  • 取消name和code的联动

    依次选择:Tools->General Operations

    出现下图界面,选择Dialog,将图中的复选框选择取消掉

    26abde2debd8ca49a377aeda4443b0c1a21.jpg

  • 在表中显示name和code

    依次选择:Tools->Display Preferences

    出现下图界面,选择Table,点击Advanced

    f76797d47ae4e9e72b4d4af0a15cf7fa259.jpg

    根据图中圈出来的部分最终确定显示的列和先后顺序

    75b79a0168b147319b5f0e7eb59485581f6.jpg

    最终的显示结果如下:

    25b27093b1190a72a3bb7b1aafcabfd83f9.jpg

  • 创建的外键关联不添加物理连接

        现在通常做数据库设计的时候不再需要外键,因为外键会严重降低性能,但powerdesigner的默认配置在使用外键时会自动添加物理连接,而且删除外键的时候会自动删掉列,这让人很痛苦,后来发现用两种方式可以避免此问题

        1.使用外键-reference(实现),但不创建连接

            PowerDesigner中配置外键关系时,如果要删除配置的外键关系,默认设置会一同删除外键列. 要更改此设置,需在菜单栏tools中打开Model Options,在Model Settings中点击Reference, 然后把"Auto-migrate columns"这个checkbox的勾去掉,即可

        2.使用追溯-traceability link(虚线),不会生成外键

            这样可能以往在视觉上效果不一样,但我建议可以这样做,避免别人误认为导出来的脚本是含有外键的

高级

  • 将name字段值放到comment

    中国用户为了方便理解,在name字段通常使用中文,最终还希望将中文添加到备注当中去。下面的操作步骤非常重要

    1.设计表的时候先不要去添加任何字段的备注,否则一会儿执行脚本将name转换为字段的时候会将之前的备注全部清除掉

    2.执行脚本

    3.添加个性化的备注,比如约定枚举值等

    版本一:name覆盖comment

        脚本内容如下:

'******************************************************************************
'* File:     name2comment.vbs
'* Title:    Name to Comment Conversion
'* Model:    Physical Data Model
'* Objects: Table, Column, View
'* Author:   steveguoshao
'* Created: 2013-11-29
'* Mod By:   
'* Modified: 
'* Version: 1.0
'* Memo:     Modify from name2code.vbs
'******************************************************************************
​
​
Option   Explicit 
ValidationMode   =   True 
InteractiveMode   =   im_Batch
​
​
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
​
​
'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view 
'   of   the   current   folder 
Private   sub   ProcessFolder(folder) 
      Dim   Tab   'running     table 
      for   each   Tab   in   folder.tables 
            if   not   tab.isShortcut   then 
                  tab.comment   =   tab.name 
                  Dim   col   '   running   column 
                  for   each   col   in   tab.columns 
                        col.comment=   col.name 
                  next 
            end   if 
      next
​
​
      Dim   view   'running   view 
      for   each   view   in   folder.Views 
            if   not   view.isShortcut   then 
                  view.comment   =   view.name 
            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

    版本2:如果comment不为空,则用name替换

Option   Explicit 
ValidationMode   =   True 
InteractiveMode   =   im_Batch 

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 

'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view 
'   of   the   current   folder 
Private   sub   ProcessFolder(folder)    
      Dim   Tab   'running     table    
      for   each   Tab   in   folder.tables    
            if   not   tab.isShortcut then
                     if  trim(tab.comment)="" then'如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面.
                        tab.comment   =   tab.name
                     end if  
                  Dim   col   '   running   column    
                  for   each   col   in   tab.columns   
                        if trim(col.comment)="" then '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避免已有注释丢失.
                           col.comment=   col.name   
                        end if 
                  next    
            end   if    
      next    
  
      Dim   view   'running   view    
      for   each   view   in   folder.Views    
            if   not   view.isShortcut and trim(view.comment)=""  then    
                  view.comment   =   view.name    
            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

将上面的内容保存到name2comment.vbs中

进入脚本执行界面

31626a400995ee124d60d6990f542931122.jpg

打开选择脚本窗口

c83423547df8bb57feeb1fbb1d8bece2e3a.jpg

选择并执行脚本

d315b0ab117313e0adce98cf9c583456d5c.jpg

然后查看你的SQL脚本

 

 

转载于:https://my.oschina.net/u/3049601/blog/1920174

相关文章:

  • 用开源技术巧解代账公司开票据难题
  • mysql 主从同步详细配置教程
  • cURL error 60: SSL certificate problem...
  • OSPF动态路由重分发实验
  • 数据库名称
  • 分库分表的面试题5
  • nginx配置.htaccess伪静态
  • pip更改国内源
  • android ndk cmake Invalid Android ABI
  • 基于命令序列的异常行为分析 业界研究现状分析
  • Python标准库(待续)
  • Python 爬虫获取网易云音乐歌手信息
  • WPF查找父元素子元素
  • 如何用vue打造一个移动端音乐播放器
  • VBoot1.0发布,Vue SpringBoot 综合开发入门
  • Docker 笔记(2):Dockerfile
  • flask接收请求并推入栈
  • IndexedDB
  • JavaScript 一些 DOM 的知识点
  • JavaScript/HTML5图表开发工具JavaScript Charts v3.19.6发布【附下载】
  • Kibana配置logstash,报表一体化
  • LeetCode算法系列_0891_子序列宽度之和
  • pdf文件如何在线转换为jpg图片
  • Python - 闭包Closure
  • webpack项目中使用grunt监听文件变动自动打包编译
  • 笨办法学C 练习34:动态数组
  • 使用Envoy 作Sidecar Proxy的微服务模式-4.Prometheus的指标收集
  • #{} 和 ${}区别
  • #QT(串口助手-界面)
  • #Z2294. 打印树的直径
  • #数学建模# 线性规划问题的Matlab求解
  • (02)vite环境变量配置
  • (9)目标检测_SSD的原理
  • (day 12)JavaScript学习笔记(数组3)
  • (大众金融)SQL server面试题(1)-总销售量最少的3个型号的车及其总销售量
  • (附源码)计算机毕业设计ssm-Java网名推荐系统
  • (每日持续更新)信息系统项目管理(第四版)(高级项目管理)考试重点整理第3章 信息系统治理(一)
  • (新)网络工程师考点串讲与真题详解
  • (原創) 是否该学PetShop将Model和BLL分开? (.NET) (N-Tier) (PetShop) (OO)
  • (终章)[图像识别]13.OpenCV案例 自定义训练集分类器物体检测
  • ..thread“main“ com.fasterxml.jackson.databind.JsonMappingException: Jackson version is too old 2.3.1
  • .NET(C#、VB)APP开发——Smobiler平台控件介绍:Bluetooth组件
  • .NET委托:一个关于C#的睡前故事
  • /proc/interrupts 和 /proc/stat 查看中断的情况
  • @AutoConfigurationPackage的使用
  • @staticmethod和@classmethod的作用与区别
  • [android]-如何在向服务器发送request时附加已保存的cookie数据
  • [APIO2012] 派遣 dispatching
  • [ARM]ldr 和 adr 伪指令的区别
  • [c]扫雷
  • [CTF]2022美团CTF WEB WP
  • [DevOps云实践] 彻底删除AWS云资源
  • [Docker]十一.Docker Swarm集群raft算法,Docker Swarm Web管理工具
  • [Erlang 0129] Erlang 杂记 VI 2014年10月28日
  • [Flex][问题笔记]TextArea滚动条问题