[Original] Use powerdesigner to create a Database Upgrade script

Source: Internet
Author: User
Tags apm powerdesigner
When using PD, many people ask if there is any function to create an automatic upgrade script. Actually, there are.

Operating principle:
1. Save the original version, save it as an APM file, and generate an archive model.
2. to generate an upgrade script, select the original version.

Procedure:
1. Open the PDM file, select Save As... Save As, select the APM file type in the pop-up window, and enter the file name to save it.
2. modify the content of the relevant data model and save it.
3. Select the modify Database... menu in the database menu.
4. After setting the Directory and file name of the upgrade script in the pop-up window, select using an archive model in the obtains database schema in the synchronization page: select the original APM file. The settings on other pages are similar to those on the script generation.

5. Click OK. The PD will automatically generate the database comparison information. A Database Synchronization window is displayed, which lists all the differences, you can select the content to be upgraded. Click OK to see the upgrade script.

Generate script analysis:
In general, it is still a very intelligent tool.
For example, adding a column makes it easy to generate a script. The script is as follows:
Alter table sy_msgsend add column_8 char (10)
/

When you delete a column, an intelligent upgrade script is fully displayed, as shown below. A series of upgrade scripts are generated when you delete a column:

/* ===================================================== ======================================= */
/* Database Name: database */
/* DBMS name: Oracle version 9i */
/* Created on: 11:12:26 */
/* ===================================================== ======================================= */

Alter table sy_msgreceiver
Drop constraint fk_sy_msgre_sy_msgrec_sy_msgse
/

Drop table tmp_sy_msgsend cascade Constraints
/

/* ===================================================== ======================================= */
/* Table: tmp_sy_msgsend */
/* ===================================================== ======================================= */

Create Table tmp_sy_msgsend (
Ms_id number (10) Not null,
Ms_content varchar2 (4000 ),
Ms_sendtime date,
Ms_type varchar2 (4 ),
Ms_sender number (8 ),
Ms_status number (1) default 1 not null,
Ms_msgsource number (2) default 1 not null,
Column_8 char (10)
)
/

 

Insert into tmp_sy_msgsend (ms_id, ms_content, ms_sendtime, ms_type, ms_sender, ms_status, ms_msgsource)
Select ms_id, ms_content, ms_sendtime, ms_type, ms_sender, ms_status, ms_msgsource
From sy_msgsend
/

Drop table sy_msgsend cascade Constraints
/

/* ===================================================== ======================================= */
/* Table: sy_msgsend */
/* ===================================================== ======================================= */

Create Table sy_msgsend (
Ms_id number (10) Not null,
Ms_content varchar2 (4000 ),
Ms_sendtime date,
Ms_type varchar2 (4 ),
Ms_sender number (8 ),
Ms_status number (1) default 1 not null,
Ms_msgsource number (2) default 1 not null,
Constraint pk_sy_msgsend primary key (ms_id)
)
Tablespace tbs_eoffice
/

Insert into sy_msgsend (ms_id, ms_content, ms_sendtime, ms_type, ms_sender, ms_status, ms_msgsource)
Select ms_id, ms_content, ms_sendtime, ms_type, ms_sender, ms_status, ms_msgsource
From tmp_sy_msgsend
/

/* ===================================================== ======================================= */
/* Index: index_47 */
/* ===================================================== ======================================= */
Create index index_47 on sy_msgsend (
Ms_sender ASC
)
Tablespace tbs_idx_eoffice
/

Alter table sy_msgreceiver
Add constraint fk_sy_msgre_sy_msgrec_sy_msgse foreign key (ms_id)
References sy_msgsend (ms_id)
On Delete Cascade
/

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.