Powerdesigner generates er diagrams in reverse, and sets Chinese annotations for table names and fields

table of Contents

1. It is recommended to export the table structure sql file from mysql first, which is much faster

2. First select one more column of code and use it as a comment

3. Modify table name comments and field comments through scripts

4. Found a bug, the er diagram imported by sql has no table name annotation. . .

5. So guessing, I should import the alter table comment script again. The test is ok! !

6. Save all the above alter scripts as a sql file, import it again, and it’s ok.


Then import powerdesigner, which is faster, much faster than connecting to mysql directly from odbc. . .

https://blog.csdn.net/csdn565973850/article/details/80812738

There is a bug, please refer to: 4. Found a bug, the er diagram imported by sql, there is no table name comment. . .

2. First select one more column of code and use it as a comment

Tools---Display Preferences

Select table, advanced options, column, filter, and check code. Save save save

3. Modify table name comments and field comments through scripts

Run the script:

The name of the table was changed to: Note+English

Change the field to: Comment/English

The following is the script, which can be saved as a vbs file and used again later.

Option ExplicitValidationMode = TrueInteractiveMode = im_Batch Dim mdl 'the current model 'get the current active modelSet mdl = ActiveModelIf (mdl Is Nothing) ThenMsgBox "There is no current Model"ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) ThenMsgBox "The current model is not an Physical Data model."ElseProcessFolder mdlEnd If 'This routine copy name into code for each table, each column and each view'of the current folderPrivate sub ProcessFolder(folder) Dim Tab 'running tablefor each Tab in folder.tablesif not tab.isShortcut thenif len(tab.comment) <> 0 then'tab.name = tab.nametab.name = tab.comment&"["&tab.name&"]"end ifOn Error Resume NextDim col 'running columnfor each col in tab.columnsif len(col.comment) <>0 thencol.name =col.commentend ifOn Error Resume Nextnextend ifnextend sub

4. Found a bug, the er diagram imported by sql has no table name annotation. . .

Left picture: odbc import, right picture: sql import

Double-click to view the table structure, as follows:

Above: odbc import, below: sql import

Above: odbc import, below: sql import

5. So guessing, I should import the alter table comment script again. The test is ok! !

The batch generated alter script sql is as follows:

SELECT t1.table_name,t1.table_comment ,CONCAT('alter table ',t1.table_name,' comment ''',t1.table_comment,''' ; ') AS comment_sql FROM information_schema.tables t1 WHERE table_schema = 'egb_new'AND t1.table_comment <>''  

6. Save all the above alter scripts as a sql file, import it again, and it’s ok.