PowerDesigner 设计数据库中常用脚本

数据库设计

物理模型设置

Name转Comment脚本

	'******************************************************************************
'* File: name2comment.vbs
'* Title: Name to Comment Conversion
'* Model: Physical Data Model
'* Objects: Table, Column, View
'* Author: steveguoshao
'* Created: 2013-11-29
'* Mod By:
'* Modified:
'* Version: 1.0
'* Memo: Modify from name2code.vbs
'****************************************************************************** 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
if trim(tab.comment)="" then'如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面.
tab.comment = tab.name
Dim col ' running column
for each col in tab.columns
if trim(col.comment)="" then '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避
col.comment= col.name
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

注释转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
'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
if len(tab.comment) <> 0 then
tab.name = tab.comment
end if
On Error Resume Next
Dim col 'running column
for each col in tab.columns
if len(col.comment) <>0 then
col.name =col.comment
end if
On Error Resume Next
next
end if
next
end sub

able加前缀脚本

	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 //如果为概念模型 为PdCDM.cls_Model
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
if InStr(tab.code,"tb_") = 0 then
tab.code="tb_"+tab.code
end if
end if
next
end sub

对应数据类型

类型 数据库类型 内容 长度
Integer int / INTEGER 32-bit integer
Short Integer int / INTEGER 32-bit integer
Byte tinyint / SMALLINT 256 values
Number numeric / NUMBER Numbers with a fixed decimal point Fixed
Decimal decimal / NUMBER Numbers with a fixed decimal point Fixed
Float float / FLOAT 32-bit floating point numbers Fixed
Short Float real / FLOAT Less than 32-bit point decimal number
Long Float double precision / BINARY DOUBLE 64-bit floating point numbers
Money money / NUMBER Numbers with a fixed decimal point Fixed
Serial numeric / NUMBER Automatically incremented numbers Fixed
Boolean bit / SMALLINT Two opposing values (true/false; yes/no; 1/0)
Characters char / CHAR Character strings Fixed
Variable Characters varchar / VARCHAR2 Character strings Maximum
Long Characters varchar / CLOB Character strings Maximum
Long Var Characters text / CLOB Character strings Maximum
Text text / CLOB Character strings Maximum
Multibyte nchar / NCHAR Multibyte character strings Fixed
Variable Multibyte nvarchar / NVARCHAR2 Multibyte character strings Maximum
Date date / DATE Day, month, year
Time time / DATE Hour, minute, and second
Date & Time datetime / DATE Date and time
Timestamp timestamp / TIMESTAMP System date and time
Binary binary / RAW Binary strings Maximum
Long Binary image / BLOB Binary strings Maximum
Bitmap image / BLOB Images in bitmap format (BMP) Maximum
Image image / BLOB Images Maximum
OLE image / BLOB OLE links Maximum
Other User-defined data type

概念模型

Name转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(PdCDM.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 Entity 'running table
for each Entity in folder.entities
if not Entity.isShortcut then
if trim(Entity.comment)="" then'如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面.
Entity.comment = Entity.name
end if
Dim Attr ' running column
for each Attr in Entity.Attributes
if trim(Attr.comment)="" then '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避
Attr.comment= Attr.name
end if
Next
end if
Next ' go into the sub-packages
Dim f ' running folder
For Each f In folder.Packages
MsgBox folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub

PowerDesigner 设计数据库中常用脚本的更多相关文章

  1. 采用PowerDesigner 设计数据库

    PowerDesigner设计数据库的教程网上都有,最好的是我一位同学写的,地址: 点击这里 我的大致流程如下: 首先要以管理员的身份打开PowerDesigner,如果没这么做,将导致后面无法创建S ...

  2. 使用POWERDESIGNER设计数据库的20条技巧(转)

    1.PowerDesigner使用MySQL的auto_increment ◇问题描述: PD怎样能使主键id使用MySQL的auto_increment呢? ◇解决方法: 打开table prope ...

  3. 新手学习数据库(一)用Powerdesigner设计数据库

    说明: 一.学会用开发语言进行数据库编程,其关键是在于学会sql语言,开发语言只不过给程序员提供了一个操作数据库的接口罢了. 二. 本人也是初学者,采用的数据库设计软件是powerdesigner.利 ...

  4. 利用PowerDesigner设计数据库

    PowerDesigner非常强大, 可以利用它完成数据库的设计. 1.下载地址:http://pan.baidu.com/s/1DsLrg 2.表设计: 建立概念数据模型(Conceptual Da ...

  5. mysql数据库中常用操作汇总

    一.查询数据库的基本信息: 1.    /* 查询数据库 ‘boss’ 所有表及注释 */SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema ...

  6. SQL2008数据库优化常用脚本

    --查询某个数据库的连接数 select count(*) from Master.dbo.SysProcesses where dbid=db_id() --前10名其他等待类型 SELECT TO ...

  7. Powerdesigner设计表生成SQL脚本(带有注释)

    网上搜索查阅地址:https://www.2cto.com/database/201704/628659.html 步骤: Powerdesigner中选择Tools---->Excute co ...

  8. 使用PowerDesigner设计数据库

    1.快捷键CTRL+N 创建 New Model 选择如下图,并设置 Model name 单击OK 2.使用工具添加实体 双击Entity_1,填上如下图信息   切换选项卡,添加属性信息 其中 M ...

  9. MySQL数据库中常用的引擎有几种?有什么区别?

    1.常用的3种  2.InnoDB Myisam Memory 3.InnoDB跟Myisam的默认索引是B+tree,Memory的默认索引是hash 区别: 1.InnoDB支持事务,支持外键,支 ...

随机推荐

  1. linux(2)系统目录结构

    前言 平常linux系统用的也不少,那么linux下的每个目录都是用来干什么的,小伙伴们有仔细研究过吗?让我们来了解下吧 Linux 系统目录结构 登录系统后,在当前命令窗口下输入命令: [root@ ...

  2. 记angular和asp.net使用grpc进行通信

    AspNetCore配置grpc服务端 新建一个Demo项目: GrpcStartup, 目录结构如下图: GrpcStartup.GrpcServices需要安装下面的依赖 <PackageR ...

  3. Testing Round #16 (Unrated)

    比赛链接:https://codeforces.com/contest/1351 A - A+B (Trial Problem) #include <bits/stdc++.h> usin ...

  4. centos7.2安装图形化界面 && 在Linux上更改当前默认界面

    安装环境 [root@desktop-test ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) 安装过程 [root@ ...

  5. C - Last Digit

    Description The function f(n, k) is defined by f(n, k) = 1k + 2k + 3k +...+ nk. If you know the valu ...

  6. Triangle War POJ - 1085 极小极大搜索

    参考链接:https://www.cnblogs.com/nwpuacmteams/articles/5697873.html 极小极大搜索 的个人理解(alpha-beta剪枝):https://w ...

  7. hdu5489 Removed Interval

    Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission ...

  8. 牛客编程巅峰赛S1第11场 - 黄金&钻石 A.牛牛的01游戏 (模拟栈)

    题意:有一个\(01\)串,两个相邻的\(0\)可以变成一个\(1\),两个相邻的\(1\)可以直接消除,问操作后的字符串. 题解:数组模拟栈直接撸,上代码吧. 代码: class Solution ...

  9. List遍历以及剔除指定数据

    一.list三种遍历方式 1.for循环 List<String> list = new ArrayList<String>(); list.add("A" ...

  10. 将从摄像头即时读入的人像放入背景视频中_with_OpenCV_in_Python

    import cv2 import numpy as np import time cap = cv2.VideoCapture(0) background_capture = cv2.VideoCa ...