What should I do if the PowerDesigner database modeling name and code write?

zhaozj2021-02-16  49

Name and Code input error: A netizen uses PowerDesigner to moderate, because it is not familiar with PowerDesigner, do not think that the column in the table will use Name instead of Code. The purpose of this netizen is to use Chinese as a comment for understanding and communication, while SQL scripts use English. However, it is because it is not clear about this concept, and the Name and Code are mistaken. In the Code input column, in the Name column, enter English. As shown below:

So the generated script is as follows:

=========================================

Create Table Students (

Int null,

Name varchar (20) null,

Age Smallint Null,

Gender Bit Null,

Married Bit Null,

ID number VARCHAR (18) NULL,

Note VARCHAR (50) NULL

)

=========================================

This is just in the same way, so, in order to correct English scripts, you have to manually re-enter Name and Code in the correct Chinese and English order, dozens of tables in the model, the work costs a lot The time of precious development has caused unnecessary losses.

discuss:

To solve this problem, we must first learn how PowerDesigner is a script. In the 2.15PoWerDesigner Variable section, many objects contain both code variables and a generated code variable (Generated Code Variable). The code variable is the attribute code defined in the object properties window, and the generated code variable is generated based on the object's property code and generated option, if the length of the code exceeds DBMS. The maximum length of the restriction is automatically intercepting the Code generation generating code. PowerDesigner generates a script by default, neither Name is named nor code, but the "generated code" generated by code (Code) as the name of the object. In general, since the Code itself does not exceed the maximum length specified in DBMS, it will give a wrong understanding, and it is considered that script generation is Code as a name. In this way, the idea of ​​solving the problem in this example is clear. If you can use Name to generate an English code, you can solve this problem. In other words, it is replaced with the Name (name) to replace the generated code. Refer to the variable list in the 2.15PowerDesigner section: "Use the variable used to define the table", you can know that Column is the generated code of the column, and colnname is a column name (Name), colncode is the column code (Code).

ColnuDe and Column are different in that column is the generated code of columns, namely colncode's code in the maximum length of DBMS. If Code is too long, it will be intercepted, and the column at this time is not equal, but usually In the case, Code does not exceed the maximum length, which is equal to Column.

solution:

As shown in the following figure, select Database-> Edit Current Database, select Script-> Object-> Column-> Add

Chart 2.15.2.1

You can see the code template in the definition table in the value editing box of the window:

=================================================================================================================================================================================

% 20: Column% [% compute%? AS (% compute%):% 20: Datatype% [% Identity%?% Identity%: [% null%] [% notnull%]] [default% default%]

[[constraint% constname%] Check (% constraint%)]]]]]

================================================15.15.2 PowerDesigner Formatting section, in addition, due to the reference to the variable needs to add "%%" in PowerDesigner, it is easy to understand "% 20: column%" in the code template indicates that the generated code of the column is fixed. 20 Bit, and what we need to do is replacing column into colname, which is to change "% 20: colnname%" to "% 20: colnname%", then click OK, pop up the confirmation window, click "Yes" to save the modify. You can view the code in the PriView property page in the table, basically solve this problem:

=================================================================================================================================================================================

Create Table Students (

Studenno int NULL,

StudentName Varchar (20) NULL,

Age Smallint Null,

Gender bit null,

Ismarried bit null,

Idcardno varchar (18) NULL,

Description varchar (50) NULL

)

=================================================================================================================================================================================

Observing code finds the name of the table or the opposite Chinese input by this netizen, we can use the same method, Database-> Edit Current Database, select Script-> Object-> Table-> Create to change% Table% to% TNAME %, This will find "student" in the script will become "student" correctly. In this way, the solution to this problem requires less than a minute, no need to manually modify the hour, let people have a sense of accomplishment.

转载请注明原文地址:https://www.9cbs.com/read-26306.html

New Post(0)