155 lines
5.1 KiB
Markdown
155 lines
5.1 KiB
Markdown
---
|
||
title: PowerDesigner
|
||
date: 2022-12-07 9:05:31
|
||
author: 文永达
|
||
top_img: https://gcore.jsdelivr.net/gh/volantis-x/cdn-wallpaper/abstract/B951AE18-D431-417F-B3FE-A382403FF21B.jpeg
|
||
---
|
||
|
||
# PowerDesigner
|
||
|
||
## 简介
|
||
|
||
PowerDesigner是图形化的建模环境,几乎包括了数据库模型设计的全过程。利用PowerDesigner可以制作数据流程图、概念数据模型、物理数据模型,可以生成多种客户端开发工具的应用程序。它可与许多流行的数据库设计模型。
|
||
|
||
## 新建数据库物理模型
|
||
|
||
File -> New Model...
|
||
|
||

|
||
Model types -> Physical Data Model -> Physical Diagram
|
||
|
||

|
||
|
||
DBMS可以选择数据库
|
||
|
||

|
||
|
||
## 修改当前DBMS
|
||
|
||
Database -> Change Current DBMS
|
||
|
||

|
||
|
||
New 选择要修改的DBMS
|
||
|
||

|
||
|
||
## 根据Name生成Comment
|
||
|
||
### SQL Server
|
||
|
||
Tools -> Resources -> DBMS...
|
||
|
||
会弹出DBMS 列表
|
||
|
||

|
||
|
||
为了不修改原有的,所以这里选择新建一个DBMS,选择New
|
||
|
||

|
||
|
||
取名,选择拷贝原有的DBMS
|
||
|
||

|
||
|
||
另存到默认路径
|
||
|
||

|
||
|
||
接着会弹出DBMS属性页面
|
||
|
||

|
||
|
||
修改关键特征树,在 Script\Objects\Table\TableComment和Script\Objects\Column\ColumnComment位置的直修改如下:
|
||
|
||
修改TableComment
|
||
|
||
修改右侧Value
|
||
|
||
```sql
|
||
EXECUTE sp_addextendedproperty
|
||
N'MS_Description', N'%COMMENT%', N'user', N'%OWNER%', N'table', N'%TABLE%', NULL, NULL
|
||
```
|
||
|
||

|
||
|
||
修改ColumnComment
|
||
|
||

|
||
|
||
```sql
|
||
EXECUTE sp_addextendedproperty
|
||
N'MS_Description', N'%Name%', N'user', N'%OWNER%', N'table', N'%TABLE%', N'column', N'%COLUMN%'
|
||
```
|
||
|
||
确定即可
|
||
|
||
修改生成数据库
|
||
|
||
Database -> Generate Database
|
||
|
||

|
||
|
||
弹出对话框
|
||
|
||
选择Format 勾选 Generate name in empty comment
|
||
|
||

|
||
|
||
否则当你备注为空的时候注释出不来;反之,如果你备注不为空那么名称(Name)才能作为注释出现!!
|
||
|
||
测试是否成功生成
|
||
|
||

|
||
|
||
成功生成
|
||
|
||
### MySQL
|
||
|
||
Database -> Edit Current DBMS...
|
||
|
||

|
||
|
||
#### 表注释
|
||
|
||
左侧菜单 Script -> Objects -> Table -> TableComment
|
||
|
||

|
||
|
||
```tex
|
||
alter table [%QUALIFIER%]%TABLE% comment %.60qA:COMMENT%
|
||
```
|
||
|
||
#### 字段注释
|
||
|
||
左侧菜单 Script -> Objects -> Column -> Add
|
||
|
||

|
||
|
||
将
|
||
|
||
|
||
```tex
|
||
%20:COLUMN% [%National%?national ]%DATATYPE%[%Unsigned%? unsigned][%ZeroFill%? zerofill][ [.O:[character set][charset]] %CharSet%][.Z:[ %NOTNULL%][%R%?[%PRIMARY%]][%IDENTITY%? auto_increment:[ default %DEFAULT%]][ comment %.q:@OBJTLABL%]]
|
||
```
|
||
|
||
修改为
|
||
|
||
```tex
|
||
%20:COLUMN% [%National%?national ]%DATATYPE%[%Unsigned%? unsigned][%ZeroFill%? zerofill][ [.O:[character set][charset]] %CharSet%][.Z:[ %NOTNULL%][%IDENTITY%? auto_increment:[ default %DEFAULT%]][ comment %.q:COMMENT%]]
|
||
```
|
||
|
||
#### 代码生成
|
||
|
||
点击菜单Database-->enerate Database
|
||
|
||

|
||
|
||
|
||
|
||
出现Database Generation屏幕:在Format tab页中,勾选Generate name in empty comment
|
||
|
||
单击确定就可以生成相应的代码,代码中就会出现上面的注释了。
|
||
|
||

|