PowerDesigner 设计数据库中常用脚本
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 设计数据库中常用脚本的更多相关文章
- 采用PowerDesigner 设计数据库
PowerDesigner设计数据库的教程网上都有,最好的是我一位同学写的,地址: 点击这里 我的大致流程如下: 首先要以管理员的身份打开PowerDesigner,如果没这么做,将导致后面无法创建S ...
- 使用POWERDESIGNER设计数据库的20条技巧(转)
1.PowerDesigner使用MySQL的auto_increment ◇问题描述: PD怎样能使主键id使用MySQL的auto_increment呢? ◇解决方法: 打开table prope ...
- 新手学习数据库(一)用Powerdesigner设计数据库
说明: 一.学会用开发语言进行数据库编程,其关键是在于学会sql语言,开发语言只不过给程序员提供了一个操作数据库的接口罢了. 二. 本人也是初学者,采用的数据库设计软件是powerdesigner.利 ...
- 利用PowerDesigner设计数据库
PowerDesigner非常强大, 可以利用它完成数据库的设计. 1.下载地址:http://pan.baidu.com/s/1DsLrg 2.表设计: 建立概念数据模型(Conceptual Da ...
- mysql数据库中常用操作汇总
一.查询数据库的基本信息: 1. /* 查询数据库 ‘boss’ 所有表及注释 */SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema ...
- SQL2008数据库优化常用脚本
--查询某个数据库的连接数 select count(*) from Master.dbo.SysProcesses where dbid=db_id() --前10名其他等待类型 SELECT TO ...
- Powerdesigner设计表生成SQL脚本(带有注释)
网上搜索查阅地址:https://www.2cto.com/database/201704/628659.html 步骤: Powerdesigner中选择Tools---->Excute co ...
- 使用PowerDesigner设计数据库
1.快捷键CTRL+N 创建 New Model 选择如下图,并设置 Model name 单击OK 2.使用工具添加实体 双击Entity_1,填上如下图信息 切换选项卡,添加属性信息 其中 M ...
- MySQL数据库中常用的引擎有几种?有什么区别?
1.常用的3种 2.InnoDB Myisam Memory 3.InnoDB跟Myisam的默认索引是B+tree,Memory的默认索引是hash 区别: 1.InnoDB支持事务,支持外键,支 ...
随机推荐
- Java排序算法(一)冒泡排序
一.测试类SortTest import java.util.Arrays; public class SortTest { private static final int L = 20; pub ...
- P4718 [模板]Pollard-Rho算法
对一个大质数进行质因数分解 需要引用miller-robin来判素数 一直写的gcd居然挂掉了... 以后用__gcd了 #include <bits/stdc++.h> using na ...
- 【洛谷 p3376】模板-网络最大流(图论)
题目:给出一个网络图,以及其源点和汇点,求出其网络最大流. 解法:网络流Dinic算法. 1 #include<cstdio> 2 #include<cstdlib> 3 #i ...
- HDU - 3613 Best Reward(manacher或拓展kmp)
传送门:HDU - 3613 题意:给出26个字母的价值,然后给你一个字符串,把它分成两个字符串,字符串是回文串才算价值,求价值最大是多少. 题解:这个题可以用马拉车,也可以用拓展kmp. ①Mana ...
- mysql 索引类型以及创建
明天就去面浦发了,感觉对数据库有些忘了,时间紧迫,就直接把链接贴这了,有空再整理. 参考: 1. https://www.cnblogs.com/crazylqy/p/7615388.html
- sscanf的最基础用法(非原创)
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 int main(){ 6 ch ...
- HDU 6623 Minimal Power of Prime(思维)题解
题意: 已知任意大于\(1\)的整数\(a = p_1^{q_1}p_2^{q_2} \cdots p_k^{q_k}\),现给出\(a \in [2,1e18]\),求\(min\{q_i\},q ...
- Gym 101174D Dinner Bet(概率DP)题解
题意:n个球,两个人每人选C个球作为目标,然后放回.每回合有放回的拿出D个球,如果有目标球,就实现了这个目标,直到至少一个人实现了所有目标游戏结束.问结束回合的期望.误差1e-3以内. 思路:概率DP ...
- AbstractQueuedSynchronizer的使用和juc里的相关类的解析
对AQS进行解析后,先来实现两个简单的基于AQS的类,然后再解析juc里基于AQS构造的类. 1.基于AQS的类的示例 首先先看这个类,这个类是<Java并发编程实战>的一个示例,AQS源 ...
- 图解 git stash
图解 git stash # 暂存本地 变化 $ git stash # 复原 $ git stash pop The "git stash" command can help y ...