这是我用来重命名“友好”名称的东西,以及我所有引用的约束名称。也许它会帮助你。
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim mdl
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 a Physical Data model."
Else
ProcessFolder mdl
End If
Private sub ProcessFolder(folder)
Dim Tab, Key, Rel
for each Rel in Folder.References
Rel.ForeignKeyConstraintName = "FK_" + UCASE(Rel.ParentTable.Name) + "_" + UCASE(Rel.ParentKeyColumnList) + "_" + UCASE(Rel.ChildTable.Name) + "_" + UCASE(Rel.ForeignKeyColumnList)
Rel.Name = "FK_" + UCASE(Rel.ParentTable.Name) + "_" + UCASE(Rel.ParentKeyColumnList) + "_" + UCASE(Rel.ChildTable.Name) + "_" + UCASE(Rel.ForeignKeyColumnList)
next
end sub