相互交流!
-
依次点击“Tools”-》"Generate Logical Data Model",如下图所示。或者直接使用快捷键
Ctrl+Shift+P打开物理模型生成选项对话框。
-
如下图所示选择号对应的数据库后,自定义物理模型的名称代码后点击确定即可生成物理模型。这里数据库类型有很多选择如:mysql,sqlserver,oracle等等,我们选择sqlserver2008,你可以随意从下拉框选择一个数据库进行生成(当然要跟你的数据库对应)!

-
注意这里生成的物理模型默认是不会生成注释的如下图所示:

怎么办呢?如何才能讲
Name列的内容拷贝到Comment这个里面呢?因为这个Commment里面的内容才会真正的转换到数据库字段的注释。这时候你需要Tools->Execute Commands->Edit/Run Scripts (或者快捷键
Ctrl+Shift+X)打开脚本执行的窗口,然后把下面的代码拷贝进行 run一下即可。'代码一:将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
这里脚本执行的很快,你也可以把脚本保存起来下次再用,执行后的效果如下所示:

我们的Comment这一行的内容已经跟Name一样了!
-
首先打开我们生成的物理模型,扩展名为pdm的文件,如下图所示,乍一看跟物理模型差不多,实际上还是有区别的!

-
然后依次如下图所示选择“Database”->"Generate Database" 或者快捷键
关键字:
