PowerDesigner use method summary

PowerDesigner is mostly used for database model design and has functions such as automatic generation of SQL statements. Of course, there are also many shortcomings, such as team sharing.

1. Set the data table display column in the PowerDesigner model view

1, Tools-Display Preference…

2, select Table under General Settings in Category on the left side of the window

3. Advanced on the right side of the window…

4. Select Columns on the left side of the window

5. In the List columns on the right side of the window, select the columns to be displayed

operation steps

2. When setting the PowerDesigner design table, automatically copy part of the name column value to the code column

1. Turn on the name/code automatic copy function . It is turned on by default.

Tool-Genneral-Options Dialog-Name to Code mirroring

2, Tools->Model Options….->Naming Convention
3. Select Name and check Enable name/code conversions.
4. Select Name To Code

.set_value(_First, true, new) .foreach_part(%Name%, "'#'").if (%_First%).delete(%CurrentPart%).enddelete .set_value(_First, false, update).else%CurrentPart%.endif.next This example uses the content behind the # of the Name content as Code .Script 2: .set_value(_First, true, new).foreach_part(%Name%, "'#'").if (%_First%)%CurrentPart%.set_value(_First, false, update).endif.next This example It takes the content before the # of the Name content as Code.

3. After importing data from the database to PowerDesigner, set the comment column value Copy to the name column

Run script Tools->Execute Commands->Edit/Run Scripts (Ctrl Shift X)

'************************************************ ******************************'* File: comment2name. vbs'* Purpose: Display the Chinese comment of the data column in the PDM graphics window of PowerDesigner'* Title: Assign the comment of the field to the name of the field'* Category: Open the physical model and run this script (Ctrl+Shift+X)'* Copyright:[email protected],2006/07/25 .'* Author: foxzz'* Created: '* Modified: '* Version: 1.0< /span>'* Comment: Traverse all the tables in the physical model and assign the comment of the field to the name of the field. ' Issues that need to be considered in the process of replacing name with comment' 1. The name must be unique, and The comment may not be unique. ' The solution is that if the comment of the field is repeated, the name of the field=comment+1, 2, 3...' 2. The comment value may be empty. In this case, the field name is not processed. ' For the oracle database, add the comment on column field name is''; to the C:/pdcomment.txt file. ' After the supplementary comment is completed, it is convenient to execute in the database'********* ************************************************** *******************Option Explicit< /span> ValidationMode = TrueInteractiveMode = im_BatchDim system, fileSet system = CreateObject("Scripting.FileSystemObject")Dim ForReading, ForWriting, ForAppending 'Open file optionForReading = 1 ' Read only span>ForWriting = 2 ' writableForAppending = 8< /span> 'Can write and append'Open text file Set file = system.Ope nTextFile("C:/pdcomment.txt", ForWriting, true)'Judge whether the current model is a physical data modelDim mdlSet mdl = ActiveModel < span class="hljs-keyword">If (mdl Is Nothing) Then MsgBox "Processing object has no model"ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then MsgBox "Current model Not a physical data model"Else ProcessFolder mdl,file End Iffile.Close'**************************** ************************************************** Private sub ProcessFolder(folder,file)Dim i,j,ki=0 :j=0:k=0'Column array, Unique comments in record fieldsDim ColumnComment() Dim ColumnCommentNumber()ReDim Preserve ColumnComment(i)ReDim Preserve ColumnCommentNumber(i)Dim tbl 'Current tableDim col 'current fielddim curComment 'Current field comment'Processing the table in the modelfor each tbl in folder. tables if not tbl.isShortcut then < span class="hljs-keyword">if len(trim(tbl.comment))<>0  then 'The comment of the table can be displayed here 'tbl.name = tbl.name+"("+trim (tbl.comment)+")" end if 'Handle columns in the table for each col in tbl.columns k = 0 curComment = trim(col.comment) if span> len(curComment)<>0 then 'traversal Distinct comment array for j = 0 to i if ColumnComment(j) = curComment then 'If the same comment is found , The relevant counter is incremented by 1 ColumnCommentNumber(j) = ColumnCommentNumber(j) + 1 k = j end< /span> if Next 'If there is no same comment, Then k=0, at this time ColumnCommentNumber(0) is also 0 'Otherwise ColumnCommentNumber(k) is not 0 if ColumnCommentNumber(k) <> 0 then col.name = curComment & cstr(ColumnCommentNumber(k)) else col.name = curComment 'ColumnComment(0), ColumnCommentNumber(0) are always Empty 'Add different comment records to the array i = i + 1 < span class="hljs-keyword">ReDim Preserve ColumnComment(i) ReDim Preserve ColumnCommentNumber(i) ColumnComment(i) = curComment ColumnCommentNumber(i) = 0 end if else 'write Into the file file.WriteLine "comment on column "+ tbl.name+"."+col.code+" is'';" end span> if next end if 'Because the names of different tables are allowed to be the same, reinitialize at this time.  'Because ColumnComment(0) and ColumnCommentNumber(0) are empty, you can keep them ReDim < span class="hljs-keyword">Preserve ColumnComment(0) ReDim Preserve ColumnCommentNumber(0) i=0:j= 0:k=0nextDim view 'current viewfor each view in folder.Views if not view.isShortcut then 'You can display the comment of the view here 'view.name = view.comment end if next'Recurse on subdirectoriesDim subpackage 'folderFor Each subpackage In folder.Packages if not subpackage.IsShortcut then ProcessFolder subpackage, file end if Nextend sub

4. Copy the value of the name column to the comment column

Run the script Tools ->Execute Commands->Edit/Run Scripts (Ctrl Shift X)

'If you want to add the name in pd to the comment automatically< /span>'If the comment is empty, fill in the name; If it is not empty, leave it unchanged, so as to avoid losing the existing comments.Option Explicit< /span> ValidationMode = TrueInteractiveMode = 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< /span> tab.isShortcut then if trim(tab.comment)="" then 'If there is a comment for the table, do not change it. If there is no comment for the table . Then add the name to the comment.  tab.comment = tab.name end if Dim col ' running column  for each col in tab.columns if trim(col.comment)= "" then 'If the comment of col is empty, then fill in the name, if there is a comment, then Do not add; this can prevent the existing comments from being lost. col.comment= col.name end if span> 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

Reference:

1. Table view in PowerDesigner Display Code and Name at the same time http://www.voidcn.com/article/p-uqeqrmdb-su.ht ml

2, PowerDesigner Name/Code automatic adjustment (transfer) http://hi.baidu.com/jonik/item/7d39588c3dda708e4514cf76

3, in the PDM graphics window of PowerDesigner Display the Chinese comment of the data column http://blog.csdn.net/zengzhe/article/details/974205

4, powerDesigner adds the name item to the comment (comment), a perfect solution! http:// www.cnblogs.com/dukey/archive/2010/01/20/dukey.html

Original: http://www.cnblogs.com/afarmer/archive/2012/11/05/2755327. html

PowerDesigner is mostly used for database model design and has functions such as automatic generation of SQL statements. Of course, there are also many shortcomings, such as team sharing.

1. Set the data table display column in the PowerDesigner model view

1, Tools-Display Preference…

2, select Table under General Settings in Category on the left side of the window

3. Advanced on the right side of the window…

4. Select Columns on the left side of the window

5. In the List columns on the right side of the window, select the columns to be displayed

operation steps

2. When setting the PowerDesigner design table, automatically copy part of the name column value to the code column

1. Turn on the name/code automatic copy function . It is turned on by default.

Tool-Genneral-Options Dialog-Name to Code mirroring

2, Tools->Model Options….->Naming Convention
3. Select Name and check Enable name/code conversions.
4. Select Name To Code

.set_value(_First, true, new) .foreach_part(%Name%, "'#'").if (%_First%).delete(%CurrentPart%).enddelete .set_value(_First, false, update).else%CurrentPart%.endif.next This example uses the content behind the # of the Name content as Code .Script 2: .set_value(_First, true, new).foreach_part(%Name%, "'#'").if (%_First%)%CurrentPart%.set_value(_First, false, update).endif.next This example It takes the content before the # of the Name content as Code.

3. After importing data from the database to PowerDesigner, set the comment column value Copy to the name column

Run script Tools->Execute Commands->Edit/Run Scripts (Ctrl Shift X)

'************************************************ ******************************'* File: comment2name. vbs'* Purpose: Display the Chinese comment of the data column in the PDM graphics window of PowerDesigner'* Title: Assign the comment of the field to the name of the field'* Category: Open the physical model and run this script (Ctrl+Shift+X)'* Copyright:[email protected],2006/07/25 .'* Author: foxzz'* Created: '* Modified: '* Version: 1.0 span>'* Comment: Traverse all tables in the physical model and assign the comment of the field to the name of the field. ' Issues that need to be considered in the process of replacing name with comment' 1. The name must be unique, and The comment may not be unique. ' The solution is that if the comment of the field is repeated, the name of the field=comment+1, 2, 3...' 2. The comment value may be empty. In this case, the field name is not processed. ' For the oracle database, add the comment on column field name is''; to the C:/pdcomment.txt file. ' After the supplementary comment is completed, it is convenient to execute in the database'********* ************************************************** *******************Option Explicit< /span> ValidationMode = TrueInteractiveMode = im_BatchDim system, fileSet system = CreateObject("Scripting.FileSystemObject")Dim ForReading, ForWriting, ForAppending 'Open file optionForReading = 1 ' Read only span>ForWriting = 2 ' writableForAppending = 8< /span> 'Can write and append'Open text file Set file = system.Ope nTextFile("C:/pdcomment.txt", ForWriting, true)'Judge whether the current model is a physical data modelDim mdlSet mdl = ActiveModel < span class="hljs-keyword">If (mdl Is Nothing) Then MsgBox "Processing object has no model"ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then MsgBox "Current model Not a physical data model"Else ProcessFolder mdl,file End Iffile.Close'**************************** ************************************************** Private sub ProcessFolder(folder,file)Dim i,j,ki=0 :j=0:k=0'Column array, Unique comments in record fieldsDim ColumnComment() Dim ColumnCommentNumber()ReDim Preserve ColumnComment(i)ReDim Preserve ColumnCommentNumber(i)Dim tbl 'Current tableDim col 'current fielddim curComment 'Current field comment'Processing the table in the modelfor each tbl in folder. tables if not tbl.isShortcut then < span class="hljs-keyword">if len(trim(tbl.comment))<>0  then 'The comment of the table can be displayed here 'tbl.name = tbl.name+"("+trim (tbl.comment)+")" end if 'Handle columns in the table for each col in tbl.columns k = 0 curComment = trim(col.comment) if span> len(curComment)<>0 then 'traversal Distinct comment array for j = 0 to i if ColumnComment(j) = curComment then 'If the same comment is found , The relevant counter is incremented by 1 ColumnCommentNumber(j) = ColumnCommentNumber(j) + 1 k = j end< /span> if Next 'If there is no same comment, Then k=0, at this time ColumnCommentNumber(0) is also 0 'Otherwise ColumnCommentNumber(k) is not 0 if ColumnCommentNumber(k) <> 0 then col.name = curComment & cstr(ColumnCommentNumber(k)) else col.name = curComment 'ColumnComment(0), ColumnCommentNumber(0) are always Empty 'Add different comment records to the array i = i + 1 < span class="hljs-keyword">ReDim Preserve ColumnComment(i) ReDim Preserve ColumnCommentNumber(i) ColumnComment(i) = curComment ColumnCommentNumber(i) = 0 end if else 'write Into the file file.WriteLine "comment on column "+ tbl.name+"."+col.code+" is'';" end span> if next end if 'Because the names of different tables are allowed to be the same, reinitialize at this time.  'Because ColumnComment(0) and ColumnCommentNumber(0) are empty, you can keep them ReDim < span class="hljs-keyword">Preserve ColumnComment(0) ReDim Preserve ColumnCommentNumber(0) i=0:j= 0:k=0nextDim view 'current viewfor each view in folder.Views if not view.isShortcut then 'You can display the comment of the view here 'view.name = view.comment end if next'Recurse on subdirectoriesDim subpackage 'folderFor Each subpackage In folder.Packages if not subpackage.IsShortcut then ProcessFolder subpackage, file end if Nextend sub

4. Copy the value of the name column to the comment column

Run the script Tools ->Execute Commands->Edit/Run Scripts (Ctrl Shift X)

'If you want to add the name in pd to the comment automatically< /span>'If the comment is empty, fill in the name; if not If it is empty, it will remain unchanged, which can avoid the loss of existing comments.Option Explicit ValidationMode = TrueInteractiveMode = 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 c ol ' 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

参考:

1、PowerDesigner中Table视图同时显示Code和Name http://www.voidcn.com/article/p-uqeqrmdb-su.html

2、PowerDesigner Name/Code自动调整(转) http://hi.baidu.com/jonik/item/7d39588c3dda708e4514cf76

3、在PowerDesigner的PDM图形窗口中显示数据列的中文注释 http://blog.csdn.net/zengzhe/article/details/974205

4、powerDesigner 把name项添加到注释(comment),完美方案! http://www.cnblogs.com/dukey/archive/2010/01/20/dukey.html

原文:http://www.cnblogs.com/afarmer/archive/2012/11/05/2755327.html

Leave a Comment

Your email address will not be published.