PowerDesigner显示Comment注释

PowerDesigner默认显示的列是Name及类型,如下图示:

现在需要显示注释列,以便使得ER图更加清晰。但是PowerDesigner勾选Comment显示没有效果,所以通过以下几步来处理:

双击表,弹出表属性对话框,切到Columns,默认是没显示Comment的,显示Comment列,操作如下:

 

 

确定保存,打开菜单 Tools>Display Perferences

 

勾选name,调整code

 

 确定后,如下

打开菜单Tools>Execute Commands>Edit/Run Script.. 或者用快捷键 Ctrl+Shift+X,执行下面的代码:

Option   Explicit     
ValidationMode   =   True     
InteractiveMode   =   im_Batch  
Dim blankStr  
blankStr   =   Space(1)  
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    
    
Private   sub   ProcessFolder(folder)     
On Error Resume Next    
      Dim   Tab   'running     table     
      for   each   Tab   in   folder.tables     
            if   not   tab.isShortcut   then     
                  tab.name   =   tab.comment    
                  Dim   col   '   running   column     
                  for   each   col   in   tab.columns     
                  if col.comment = "" or replace(col.comment," ", "")="" Then  
                        col.name = blankStr  
                        blankStr = blankStr & Space(1)  
                  else    
                        col.name = col.comment     
                  end if    
                  next     
            end   if     
      next    
    
      Dim   view   'running   view     
      for   each   view   in   folder.Views     
            if   not   view.isShortcut   then     
                  view.name   =   view.comment     
            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的列的值,替换成注释的值,所以下次如果调整comment,还要重新执行脚本,所以最好放在最后执行。

切换database类型

 

 

数据库表脚本包含双引号问题的解决方法

在 PowerDesigner 中的 Database -> Edit Currnet DBMS -> Script -> Sql -> Format -> CaseSensitivityUsingQuote 中选择 No,即可:

 

 

 

 

{        "id": "0050d3b64520efc0",        "type": "tab",        "label": "sqlserver",        "disabled": false,        "info": "",        "env": []    },    {        "id": "50444b205365b7b1",        "type": "inject",        "z": "0050d3b64520efc0",        "name": "",        "props": [            {                "p": "payload"            },            {                "p": "topic",                "vt": "str"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "",        "payloadType": "date",        "x": 430,        "y": 160,        "wires": [            [                "05980f64a43546e3"            ]        ]    },    {        "id": "205e1dc78be2b277",        "type": "debug",        "z": "0050d3b64520efc0",        "name": "debug 124",        "active": true,        "tosidebar": true,        "console": true,        "tostatus": true,        "complete": "payload",        "targetType": "msg",        "statusVal": "payload",        "statusType": "auto",        "x": 840,        "y": 160,        "wires": []    },    {        "id": "0623f8dda03d7cd7",        "type": "comment",        "z": "0050d3b64520efc0",        "name": "sqlserver 创建表",        "info": "",        "x": 160,        "y": 160,        "wires": []    },    {        "id": "05980f64a43546e3",        "type": "MSSQL",        "z": "0050d3b64520efc0",        "mssqlCN": "49a8339514344c57",        "name": "",        "query": "CREATE TABLE [user2] (id VARCHAR(128) NOT NULL,name VARCHAR(128) DEFAULT NULL,pass VARCHAR(128) DEFAULT NULL,create_time DATETIME DEFAULT GETDATE(),update_time DATETIME DEFAULT GETDATE(),PRIMARY KEY (id));",        "outField": "payload",        "x": 640,        "y": 160,        "wires": [            [                "205e1dc78be2b277"            ]        ]    },    {        "id": "90aef4487e33db0f",        "type": "comment",        "z": "0050d3b64520efc0",        "name": "sqlserver 插入值(固定值)",        "info": "",        "x": 200,        "y": 460,        "wires": []    },    {        "id": "a63859c171ea7853",        "type": "inject",        "z": "0050d3b64520efc0",        "name": "",        "props": [            {                "p": "payload"            },            {                "p": "topic",                "vt": "str"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "",        "payloadType": "date",        "x": 430,        "y": 460,        "wires": [            [                "f2388da6cc16b183"            ]        ]    },    {        "id": "7bd4974d9b1b2336",        "type": "debug",        "z": "0050d3b64520efc0",        "name": "debug 125",        "active": true,        "tosidebar": true,        "console": true,        "tostatus": true,        "complete": "payload",        "targetType": "msg",        "statusVal": "payload",        "statusType": "auto",        "x": 840,        "y": 460,        "wires": []    },    {        "id": "f2388da6cc16b183",        "type": "MSSQL",        "z": "0050d3b64520efc0",        "mssqlCN": "49a8339514344c57",        "name": "",        "query": "INSERT INTO [user2]  (id, name, pass)\nVALUES ('2', 'luvk', '30');",        "outField": "payload",        "x": 640,        "y": 460,        "wires": [            [                "7bd4974d9b1b2336"            ]        ]    },    {        "id": "82c0cecdbe6cb93d",        "type": "comment",        "z": "0050d3b64520efc0",        "name": "sqlserver 更新语句",        "info": "",        "x": 170,        "y": 580,        "wires": []    },    {        "id": "7ea630879fe10a7c",        "type": "inject",        "z": "0050d3b64520efc0",        "name": "",        "props": [            {                "p": "payload"            },            {                "p": "topic",                "vt": "str"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "",        "payloadType": "date",        "x": 430,        "y": 580,        "wires": [            [                "721c3549f471cd91"            ]        ]    },    {        "id": "8549f456d149478e",        "type": "debug",        "z": "0050d3b64520efc0",        "name": "debug 126",        "active": true,        "tosidebar": true,        "console": true,        "tostatus": true,        "complete": "payload",        "targetType": "msg",        "statusVal": "payload",        "statusType": "auto",        "x": 840,        "y": 580,        "wires": []    },    {        "id": "721c3549f471cd91",        "type": "MSSQL",        "z": "0050d3b64520efc0",        "mssqlCN": "49a8339514344c57",        "name": "",        "query": "UPDATE [user2]\nSET name = 'cc'\nWHERE id = 1;",        "outField": "payload",        "x": 640,        "y": 580,        "wires": [            [                "8549f456d149478e"            ]        ]    },    {        "id": "247d024ec99b6548",        "type": "inject",        "z": "0050d3b64520efc0",        "name": "",        "props": [            {                "p": "payload"            },            {                "p": "topic",                "vt": "str"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "",        "payloadType": "date",        "x": 430,        "y": 260,        "wires": [            [                "3d8078187ea32c21"            ]        ]    },    {        "id": "d93cc43727388ca4",        "type": "debug",        "z": "0050d3b64520efc0",        "name": "debug 127",        "active": true,        "tosidebar": true,        "console": true,        "tostatus": true,        "complete": "payload",        "targetType": "msg",        "statusVal": "payload",        "statusType": "auto",        "x": 840,        "y": 260,        "wires": []    },    {        "id": "93265186c022908e",        "type": "comment",        "z": "0050d3b64520efc0",        "name": "sqlserver 创建触发器create_time",        "info": "",        "x": 210,        "y": 260,        "wires": []    },    {        "id": "3d8078187ea32c21",        "type": "MSSQL",        "z": "0050d3b64520efc0",        "mssqlCN": "49a8339514344c57",        "name": "",        "query": "-- 创建触发器\nCREATE TRIGGER [user2_after_insert_trigger]\nON [user2]\nAFTER INSERT\nAS\nBEGIN\n    UPDATE [user2]\n    SET create_time = GETDATE()\n    WHERE id IN (SELECT id FROM inserted);\nEND;\n\n",        "outField": "payload",        "x": 640,        "y": 260,        "wires": [            [                "d93cc43727388ca4"            ]        ]    },    {        "id": "afffde3e03143b47",        "type": "inject",        "z": "0050d3b64520efc0",        "name": "",        "props": [            {                "p": "payload"            },            {                "p": "topic",                "vt": "str"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "",        "payloadType": "date",        "x": 430,        "y": 360,        "wires": [            [                "fd2b020e28f720fc"            ]        ]    },    {        "id": "432d297b7b56b66b",        "type": "debug",        "z": "0050d3b64520efc0",        "name": "debug 128",        "active": true,        "tosidebar": true,        "console": true,        "tostatus": true,        "complete": "payload",        "targetType": "msg",        "statusVal": "payload",        "statusType": "auto",        "x": 840,        "y": 360,        "wires": []    },    {        "id": "da86016c2ecaeabe",        "type": "comment",        "z": "0050d3b64520efc0",        "name": "sqlserver 创建触发器update_time",        "info": "",        "x": 210,        "y": 360,        "wires": []    },    {        "id": "fd2b020e28f720fc",        "type": "MSSQL",        "z": "0050d3b64520efc0",        "mssqlCN": "49a8339514344c57",        "name": "",        "query": "CREATE TRIGGER [user2_after_update_trigger]\nON [user2]\nAFTER UPDATE\nAS\nBEGIN\n    UPDATE [user2]\n    SET update_time = GETDATE()\n    WHERE id IN (SELECT id FROM inserted);\nEND;\n\n",        "outField": "payload",        "x": 640,        "y": 360,        "wires": [            [                "432d297b7b56b66b"            ]        ]    },    {        "id": "b85037e9a7c7adeb",        "type": "comment",        "z": "0050d3b64520efc0",        "name": "sqlserver 查看语句",        "info": "",        "x": 170,        "y": 680,        "wires": []    },    {        "id": "e8137588ad614ddb",        "type": "inject",        "z": "0050d3b64520efc0",        "name": "",        "props": [            {                "p": "payload"            },            {                "p": "topic",                "vt": "str"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "",        "payloadType": "date",        "x": 430,        "y": 680,        "wires": [            [                "5e12a9e7cbe29d1c"            ]        ]    },    {        "id": "8f81bce657ac3e85",        "type": "debug",        "z": "0050d3b64520efc0",        "name": "debug 129",        "active": true,        "tosidebar": true,        "console": true,        "tostatus": true,        "complete": "payload",        "targetType": "msg",        "statusVal": "payload",        "statusType": "auto",        "x": 830,        "y": 680,        "wires": []    },    {        "id": "5e12a9e7cbe29d1c",        "type": "MSSQL",        "z": "0050d3b64520efc0",        "mssqlCN": "49a8339514344c57",        "name": "",        "query": "select * from [user];",        "outField": "payload",        "x": 640,        "y": 680,        "wires": [            [                "8f81bce657ac3e85"            ]        ]    },    {        "id": "c45827576367c305",        "type": "comment",        "z": "0050d3b64520efc0",        "name": "sqlserver 删除语句",        "info": "",        "x": 170,        "y": 780,        "wires": []    },    {        "id": "e50bd5706ed4e109",        "type": "inject",        "z": "0050d3b64520efc0",        "name": "",        "props": [            {                "p": "payload"            },            {                "p": "topic",                "vt": "str"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "",        "payloadType": "date",        "x": 430,        "y": 780,        "wires": [            [                "db6f27bb68271e21"            ]        ]    },    {        "id": "6ab8984efdf4fe38",        "type": "debug",        "z": "0050d3b64520efc0",        "name": "debug 130",        "active": true,        "tosidebar": true,        "console": true,        "tostatus": true,        "complete": "payload",        "targetType": "msg",        "statusVal": "payload",        "statusType": "auto",        "x": 830,        "y": 780,        "wires": []    },    {        "id": "db6f27bb68271e21",        "type": "MSSQL",        "z": "0050d3b64520efc0",        "mssqlCN": "49a8339514344c57",        "name": "",        "query": "DELETE FROM [user2]\nWHERE id = 2;\n",        "outField": "payload",        "x": 640,        "y": 780,        "wires": [            [                "6ab8984efdf4fe38"            ]        ]    },    {        "id": "49a8339514344c57",        "type": "MSSQL-CN",        "name": "",        "server": "127.0.0.1",        "encyption": true,        "database": "mssql_jk"    }]
最新发布
03-12
### 创建表 在 SQL Server 中,创建新表使用 `CREATE TABLE` 语句。此命令允许定义列名、数据类型以及其他约束条件。 ```sql CREATE TABLE Student ( StudentID INT PRIMARY KEY, Name NVARCHAR(50), GraduationYear SMALLINT ); ``` ### 插入记录 向已存在的表中添加新的行可通过 `INSERT INTO` 命令完成。这会指定目标表格名称及其字段列表,并提供相应的值集合。 ```sql INSERT INTO Student (StudentID, Name, GraduationYear) VALUES (1, N'张三', 2023), (2, N'李四', 2024); ``` ### 更新记录 为了更改现有条目内的某些属性或者全部内容,则需要用到 `UPDATE` 指令。它能够定位特定的记录并通过设置子句改变其特性。 ```sql UPDATE Student SET GraduationYear = 2025 WHERE StudentID = 1; ``` ### 创建触发器 触发器是一种特殊的存储过程,在发生指定事件时自动激活并运行预设逻辑。下面的例子展示了当从 `Student` 表删除某位学员的信息时同步清除关联书籍借用历史的功能[^2]: ```sql CREATE TRIGGER triDeStudent ON Student FOR DELETE AS BEGIN DELETE BorrowRecord FROM BorrowRecord br JOIN DELETED d ON br.StudentID = d.StudentID; END; ``` ### 删除记录 移除数据库里的单个或多个实例可借助于 `DELETE FROM` 结构实现。通过附加适当的选择标准来限定受影响范围。 ```sql DELETE FROM Student WHERE StudentID = 1; ``` 上述操作涵盖了基本 CRUD 功能(Create, Read, Update, Delete),并且引入了触发器机制用于维护不同实体间的一致性和完整性关系。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shibushi114

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值