• PowerDesigner 常用配置修改


    PowerDesigner中Name与Code同步的问题

    转自:http://blog.sina.com.cn/u/48932504010005t9

    PowerDesigner中,但修改了某个字段的name,其code也跟着修改,这个问题很讨厌,因为一般来说,name是中文的,code是字段名。
    解决方法如下:
    1、选择Tools->GeneralOptions...菜单,出现General Options对话框。
    2、从Category中选择Dialog项。
    3、取消右边“Name to Code mirroring”复选框。如下图:
    http://p.blog.csdn.net/images/p_blog_csdn_net/forlinux/EntryImages/20080924/powerdesigner_15_overview.JPG
    --------------------------------------------------------------------------------------------
    PowerDesigner comment与name相互复制

    转自:http://www.cnblogs.com/cxd4321/archive/2009/03/07/1405475.html

    作者:剑飘红

    在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文。Name用来显 示,Code在代码中使用,但Comment中的文字会保存到数据库Table或Column的Comment中,当Name已经存在的时候,再写一次 Comment很麻烦,可以使用以下代码来解决这个问题:

    • 代码一:将Name中的字符COPY至Comment中

      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

    --------------------------------------------

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

    • 代码二:将Comment中的字符COPY至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
      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="" then
                        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

    以上两段代码都是VB脚本,在PowerDesigner中使用方法为:

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

    将代码Copy进去执行就可以了,是对整个CDM或PDM进行操作

     

    ----------------------------------------------------------------------------------------------

    PowerDesigner中配置外键关系时,

    如果要删除配置的外键关系,

    默认设置会一同删除外键列.

    要更改此设置,

    需在菜单栏tools中打开Model Options,

    在Model Settings中点击Reference,

    然后把"Auto-migrate columns"[自动移除列]这个checkbox的勾去掉,即可.

     

    ------------------------------------------------------------------------------------

    让PowerDesigner自动使用Name作为备注

    Database->Database Generation

    ------------------------------------------------------------------------

    去掉 Chinese_PRC

    今天在使用PowerDesigner 16设计数据库时,导出的sql语句在SqlServer中执行时,意外的让人悲催、抓狂、甚至想自杀!!!

    其中就有如题这样的一个错误,看下面sql语句:

    复制代码
          create table dbo.t_call_note (             id             int                  identity(100,1),              name           char(19)             collate Chinese_PRC_Stroke_90_CS_AS_KS_WS not null,             pwd            char(19)             collate Chinese_PRC_Stroke_90_CS_AS_KS_WS null,            constraint PK_T_CALL_INFO primary key (id)   on "PRIMARY"        )        on "PRIMARY"        go  
    复制代码

    其中SqlServer报错:collate chinese_prc_ci_as意外。。。

    上面的sql包含collate Chinese_PRC_Stroke_90_CS_AS_KS_WS not null,这是一种排序方式。

    但是在执行sql时就会出现错误.如果column为int时就会报错。那么我们如果如下设置,问题不再是问题了。

    解决方案:

      1.点击:工具栏-》database-》edit current DBMS

          2.选择数据源(以SqlServer2005为例)

          Microsoft SQLServer2005ScriptObjectsColumnAdd

    将如下代改

    %20:COLUMN% [%COMPUTE%?AS [(]%COMPUTE%[)]:[%.L:DATATYPE%=xml?xml[%XMLSchemaCollection%?([%ContentType% ]%XMLSchemaCollection.GeneratedName%):]:%20:DATATYPE%][.Z:[ collate %ExtCollation%][%allowFilestream%?[%FileStream%? filestream]][%ExtRowGuidCol%? RowGuidCol][%Mandatory%?:[%Sparse%? sparse]][%IDENTITY%? %IDENTITY%[[(%ExtIdentitySeedInc%)][%ExtIdtNotForReplication%? not for replication]]:[%ExtNullConstName%? constraint %ExtNullConstName%][ %NULL%][ %NOTNULL%]][[%ExtDeftConstName%? constraint %ExtDeftConstName%] default %DEFAULT%]]
       [%CONSTDEFN%]]
     
    改为下面代码:
     %20:COLUMN% 
    [%COMPUTE%?AS (%COMPUTE%):
    [%.L:DATATYPE%=xml?xml
    [%XMLSchemaCollection%?(
    [%ContentType%
    ]%XMLSchemaCollection.GeneratedName%):]:%20:DATATYPE%]
    [
    %ExtRowGuidCol%? RowGuidCol]
    [
    %IDENTITY%? %IDENTITY%[[(%ExtIdentitySeedInc%)]
    [
    %ExtIdtNotForReplication%? not for replication]]:[%ExtNullConstName%? constraint %ExtNullConstName%]
    [
    %NULL%][ %NOTNULL%]][
    [%ExtDeftConstName%? constraint %ExtDeftConstName%] default %DEFAULT%]
    [%CONSTDEFN%]]

    保存即可。

    重新生成。。。发现已经没有了。。collate chinese_prc_ci_as

    惊喜!!!!





  • 相关阅读:
    关于轨道交通的一些知识点和关键词
    关于芯片的一些关键词
    关于ADC采集
    Linux记录
    在VMware运行Linux下,密码错误的原因
    气体传感器
    AD采集问题
    Maven [ERROR] 不再支持源选项 5,请使用 7 或更高版本的解决办法
    Maven 专题(九):后记
    Maven 专题(六):Maven核心概念详解(二)
  • 原文地址:https://www.cnblogs.com/biyusoft/p/3351471.html
Copyright © 2020-2023  润新知