Show TOC

Customizing Creation StatementsLocate this document in the navigation structure

You can insert custom scripts at the beginning and end of database, table, tablespace and other objects' creation statements directly from their property sheets. For example, access rights can be added under a table creation script. You can modify the standard creation statements for these and other objects by editing the DBMS definition file.

Context

Open the property sheet of the object for which you want to specify a script, and click the Script tab. To open the script in your preferred editor (see Core Features Guide > Modeling with PowerDesigner > Customizing Your Modeling Environment > General Options > Text Editors), press Ctrl + E or click the Edit With tool.

The following variables are commonly used in begin and end scripts:

Variable

Description

%DATABASE%, %DBMSNAME%

Name of the database and of the DBMS definition file.

%NAMESCRIPT%, %PATHSCRIPT%

Filename or path of script file

%STARTCMD%

Command that runs the script

%AUTHOR%, %DATE%

Author of the current model, and date of script generation.

%TABLESPACE%

Code of the tablespace.

%TABLE%

Name or code of table (based on display preferences).

%TNAME%, %TCODE%, %TLABL%

Name, code, or label of the table.

%OWNER%, %OWNERPREFIX%

Owner or owner prefix of the table or tablespace.

%COLNLIST%

List of the table's columns.

%OPTIONS%

Physical options defined on the object.

The begin and end scripts are placed directly before and after the create statement. The SQL snippet below shows where the BeforeCreate, Header, Footer, and AfterCreate scripts that you can define in the DBMS file for these and other objects are placed around the create statement:
This is my BeforeCreate script.
/*==============================================================*/
/* Table: TABLE_1                                               */
/*==============================================================*/
This is my Header script.
This is my Begin script
create table TABLE_1 
(
   COLUMN_1             CHAR(10),
   COLUMN_2             CHAR(10),
   COLUMN_3             CHAR(10),
   constraint PK_TABLE_1 primary key ()
);

This is my End script
This is my Footer script.
This is my AfterCreate script.
For detailed information about editing DBMS definition files, including using the PDM variables, see Customizing and Extending PowerDesigner > DBMS Definition Files.