物理数据模型小技巧和错误解决

开发工具与关键技术:VS   物理数据模型
作者:听民谣的老猫
撰写时间:2019/5/10   17:15

分享一下最近用到的PowerDesigner物理数据模型小技巧和错误的解决

搭建好物理数据模型创建数据库操作
Database ——> Generate Database然后会弹出General页面
在这里插入图片描述
选择好路径点击确定就会在指定位置生成数据库脚本,当然这是在你不报错的情况下。分享一下我的错误。

错误一:
在这里插入图片描述
点开这些错误你就可以很清楚的知道错误点在哪
在这里插入图片描述
个人解决办法:再物理数据模型找到这两个表,删除关系。当然你的记得这两个表的关系,在数据库生成表的时候你可以再填加一个外键。(如果这样的关系报错有很多建议用笔记本记一下)

错误二:
在这里插入图片描述
解决方法:Database ——> Generate Database在弹出General页面将Check model那个勾去掉。具体位置第一张图有画红线。

错误三:
在这里插入图片描述
数据库执行时报错其实你就看着数据库提示去脚本里面找就OK了,虽然没有行数但是脚本会报错提示。

技巧分享:
在这里插入图片描述

物理模型导出数据库时将name作为code的注释行 ,在数据库就不用很麻烦的去写注释
Tools --> Execute Commands --> Edit/Run Script 在弹出窗口中输入下面代码。
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 code 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 + col.comment
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
点击执行后关闭提示框打开Database ——> Generate Database打开Format页面
在这里插入图片描述
勾选Generate name in empty comment这样就可以将name作为code的注释行了。
在这里插入图片描述
name作为code数据库脚本
(代码是网上搜的,在这分享一下)

猜你喜欢

转载自blog.csdn.net/weixin_44540236/article/details/90288197